1 | <?php |
||
6 | class MultichainClientTest extends \PHPUnit_Framework_TestCase |
||
7 | { |
||
8 | |||
9 | /** @var MultichainClient */ |
||
10 | protected $multichain; |
||
11 | |||
12 | /** @var MultichainHelper */ |
||
13 | protected $helper; |
||
14 | |||
15 | public function setUp() |
||
20 | |||
21 | /** |
||
22 | * Returns general information about this node and blockchain. MultiChain adds some fields to Bitcoin Core’s |
||
23 | * response, giving the blockchain’s chainname, description, protocol, peer-to-peer port. The setupblocks field |
||
24 | * gives the length in blocks of the setup phase in which some consensus constraints are not applied. The |
||
25 | * nodeaddress can be passed to other nodes for connecting. |
||
26 | * |
||
27 | * @group info |
||
28 | */ |
||
29 | public function testGetInfo() |
||
33 | |||
34 | /** |
||
35 | * Returns information about the other nodes to which this node is connected. If this is a MultiChain blockchain, |
||
36 | * includes handshake and handshakelocal fields showing the remote and local address used during the handshaking |
||
37 | * for that connection. |
||
38 | * |
||
39 | * @group info |
||
40 | */ |
||
41 | public function testGetPeerInfo() |
||
45 | |||
46 | /** |
||
47 | * Returns a new address for receiving payments. Omit the account parameter for the default account – see note |
||
48 | * about accounts. |
||
49 | * |
||
50 | * @group address |
||
51 | */ |
||
52 | public function testGetNewAddress() |
||
56 | |||
57 | /** |
||
58 | * Outputs a list of available API commands, including MultiChain-specific commands. |
||
59 | * |
||
60 | * @group info |
||
61 | */ |
||
62 | public function testHelp() |
||
66 | |||
67 | /** |
||
68 | * Sends one or more assets to address, returning the txid. In Bitcoin Core, the amount field is the quantity of |
||
69 | * the bitcoin currency. For MultiChain, an {"asset":qty, ...} object can be used for amount, in which each asset |
||
70 | * is an asset name, ref or issuance txid, and each qty is the quantity of that asset to send (see native assets). |
||
71 | * Use "" as the asset inside this object to specify a quantity of the native blockchain currency. See also |
||
72 | * sendassettoaddress for sending a single asset and sendfromaddress to control the address whose funds are used. |
||
73 | * |
||
74 | * @group transaction |
||
75 | */ |
||
76 | public function testSendToAddress(){ |
||
82 | |||
83 | /** |
||
84 | * @param $address |
||
85 | * @return mixed |
||
86 | */ |
||
87 | private function createTestAsset($address){ |
||
96 | |||
97 | /** |
||
98 | * Returns information about address including a check for its validity. |
||
99 | * |
||
100 | * @group address |
||
101 | */ |
||
102 | public function testValidateAddress() |
||
107 | |||
108 | /** |
||
109 | * Adds to the atomic exchange transaction in hexstring given by a previous call to createrawexchange or |
||
110 | * appendrawexchange. This adds an offer to exchange the asset/s in output vout of transaction txid for qty units |
||
111 | * of asset, where asset is an asset name, ref or issuance txid. The txid and vout should generally be taken from |
||
112 | * the response to preparelockunspent or preparelockunspentfrom. Multiple items can be specified within the fourth |
||
113 | * parameter to request multiple assets. Returns a raw hexadecimal transaction in the hex field alongside a |
||
114 | * complete field stating whether the exchange is complete (i.e. balanced) or not. If complete, the transaction |
||
115 | * can be transmitted to the network using sendrawtransaction. If not, it can be passed to a further counterparty, |
||
116 | * who can call decoderawexchange and appendrawexchange as appropriate. |
||
117 | * |
||
118 | * @group exchange |
||
119 | */ |
||
120 | public function testAppendRawExchange(){ |
||
127 | |||
128 | /** |
||
129 | * Creates a new atomic exchange transaction which offers to exchange the asset/s in output vout of transaction |
||
130 | * txid for qty units of asset, where asset is an asset name, ref or issuance txid. The txid and vout should |
||
131 | * generally be taken from the response to preparelockunspent or preparelockunspentfrom. Multiple items can be |
||
132 | * specified within the third parameter to request multiple assets. Returns a raw partial transaction in |
||
133 | * hexadecimal which can be passed to the counterparty, who can call decoderawexchange and appendrawexchange |
||
134 | * as appropriate. |
||
135 | * |
||
136 | * @group exchange |
||
137 | */ |
||
138 | public function testCreateRawExchange(){ |
||
145 | |||
146 | /** |
||
147 | * Decodes the raw exchange transaction in hexstring, given by a previous call to createrawexchange or |
||
148 | * appendrawexchange. Returns details on the offer represented by the exchange and its present state. The offer |
||
149 | * field in the response lists the quantity of native currency and/or assets which are being offered for exchange. |
||
150 | * The ask field lists the native currency and/or assets which are being asked for. The candisable field specifies |
||
151 | * whether this wallet can disable the exchange transaction by double-spending against one of its inputs. The |
||
152 | * cancomplete field specifies whether this wallet has the assets required to complete the exchange. The |
||
153 | * complete field specifies whether the exchange is already complete (i.e. balanced) and ready for sending. If |
||
154 | * verbose is true then all of the individual stages in the exchange are listed. Other fields relating to fees are |
||
155 | * only relevant for blockchains which use a native currency. |
||
156 | * |
||
157 | * @group exchange |
||
158 | */ |
||
159 | public function testDecodeRawExchange(){ |
||
168 | |||
169 | /** |
||
170 | * Sends a transaction to disable the offer of exchange in hexstring, returning the txid. This is achieved by |
||
171 | * spending one of the exchange transaction’s inputs and sending it back to the wallet. To check whether this can |
||
172 | * be used on an exchange transaction, check the candisable field of the output of decoderawexchange. |
||
173 | * |
||
174 | * @group exchange |
||
175 | */ |
||
176 | public function testDisableRawTransaction(){ |
||
184 | |||
185 | /** |
||
186 | * Prepares an unspent transaction output (useful for building atomic exchange transactions) containing qty units |
||
187 | * of asset, where asset is an asset name, ref or issuance txid. Multiple items can be specified within the first |
||
188 | * parameter to include several assets within the output. The output will be locked against automatic selection for |
||
189 | * spending unless the optional lock parameter is set to false. Returns the txid and vout of the prepared output. |
||
190 | * |
||
191 | * @group exchange |
||
192 | */ |
||
193 | public function testPrepareLockUnspent(){ |
||
198 | |||
199 | /** |
||
200 | * Adds a metadata output to the raw transaction in tx-hex given by a previous call to createrawtransaction. The |
||
201 | * metadata is specified in data-hex in hexadecimal form and added in a new OP_RETURN transaction output. The |
||
202 | * transaction can then be signed and transmitted to the network using signrawtransaction and sendrawtransaction. |
||
203 | * |
||
204 | * @group metadata |
||
205 | */ |
||
206 | public function testAppendRawMetadata(){ |
||
214 | |||
215 | /** |
||
216 | * Sends transactions to combine large groups of unspent outputs (UTXOs) belonging to the same address into a |
||
217 | * single unspent output, returning a list of txids. This can improve wallet performance, especially for miners in |
||
218 | * a chain with short block times and non-zero block rewards. Set addresses to a comma-separated list of addresses |
||
219 | * to combine outputs for, or * for all addresses in the wallet. Only combine outputs with at least minconf |
||
220 | * confirmations, and use between mininputs and maxinputs per transaction. A single call to combineunspent can |
||
221 | * create up to maxcombines transactions over up to maxtime seconds. See also the autocombine runtime parameters. |
||
222 | * |
||
223 | * @group operations |
||
224 | */ |
||
225 | public function testCombineUnspent(){ |
||
228 | |||
229 | /** |
||
230 | * Returns a list of all the asset balances for address in this node’s wallet, with at least minconf confirmations. |
||
231 | * Use includeLocked to include unspent outputs which have been locked, e.g. by a call to preparelockunspent. |
||
232 | * |
||
233 | * @group address |
||
234 | */ |
||
235 | public function testGetAddressBalances(){ |
||
240 | |||
241 | |||
242 | /** |
||
243 | * Returns a list of addresses in this node’s wallet. Set verbose to true to get more information about each |
||
244 | * address, formatted like the output of the validateaddress command. |
||
245 | * |
||
246 | * @group address |
||
247 | */ |
||
248 | public function testGetAddresses() |
||
252 | |||
253 | /** |
||
254 | * Provides information about transaction txid related to address in this node’s wallet, including how it affected |
||
255 | * that address’s balance. Use verbose to provide details of transaction inputs and outputs. |
||
256 | * |
||
257 | * @group address |
||
258 | * @group transaction |
||
259 | */ |
||
260 | public function testGetAddressTransaction(){ |
||
267 | |||
268 | /** |
||
269 | * Returns a list of all the asset balances for account in this node’s wallet, with at least minconf confirmations. |
||
270 | * Omit the account parameter or use "" for the default account – see note about accounts. Use includeWatchOnly to |
||
271 | * include the balance of watch-only addresses and includeLocked to include unspent outputs which have been locked, |
||
272 | * e.g. by a call to preparelockunspent. |
||
273 | * |
||
274 | * @group test |
||
275 | */ |
||
276 | public function testGetAssetBalances(){ |
||
279 | |||
280 | /** |
||
281 | * Returns a list of all the parameters of this blockchain, reflecting the content of its params.dat file. |
||
282 | * |
||
283 | * @group info |
||
284 | */ |
||
285 | public function testGetBlockchainParams() |
||
289 | |||
290 | /** |
||
291 | * Creates a new asset name on the blockchain, sending the initial qty units to address. The smallest transactable |
||
292 | * unit is given by units, e.g. 0.01. If the chain uses a native currency, you can send some with the new asset |
||
293 | * using the native-amount parameter. Returns the txid of the issuance transaction. For more information, see |
||
294 | * native assets. |
||
295 | * |
||
296 | * @group asset |
||
297 | */ |
||
298 | public function testIssue() |
||
306 | |||
307 | /** |
||
308 | * Returns information about all assets issued on the blockchain. If an asset name, ref or issuance txid (see |
||
309 | * native assets) is provided in asset, then information is only returned about that one asset. |
||
310 | * |
||
311 | * @group asset |
||
312 | */ |
||
313 | public function testListAssets() |
||
317 | |||
318 | /** |
||
319 | * Lists information about the count most recent transactions in this node’s wallet, including how they affected |
||
320 | * the node’s total balance. Use skip to go back further in history and includeWatchOnly to consider watch-only |
||
321 | * addresses as if they belong to this wallet. Use verbose to provide the details of transaction inputs and |
||
322 | * outputs. Note that unlike Bitcoin Core’s listtransactions command, the response contains one element per |
||
323 | * transaction, rather than one per transaction output. |
||
324 | * |
||
325 | * @group transaction |
||
326 | */ |
||
327 | public function testListWalletTransactions() |
||
331 | } |
||
332 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.