-- cgit v1.2.3 -- cgit v1.2.3 From 5f0de0523da8c864e43f60e4eb5193b5095e48cf Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 22 Apr 2015 12:17:00 +0200 Subject: fix StateLoader --- bcRPC_API_TestFiller.json | 579 ---------------------------------------------- 1 file changed, 579 deletions(-) delete mode 100644 bcRPC_API_TestFiller.json diff --git a/bcRPC_API_TestFiller.json b/bcRPC_API_TestFiller.json deleted file mode 100644 index b31f1fa4..00000000 --- a/bcRPC_API_TestFiller.json +++ /dev/null @@ -1,579 +0,0 @@ -{ - "RPC_API_Test" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "3141592", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "create contract: 6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "data" : "0x5b5b610705806100106000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063102accc11461012c57806312a7b9141461013a5780631774e6461461014c5780631e26fd331461015d5780631f9030371461016e578063343a875d1461018057806338cc4831146101955780634e7ad367146101bd57806357cb2fc4146101cb57806365538c73146101e057806368895979146101ee57806376bc21d9146102005780639a19a9531461020e5780639dc2c8f51461021f578063a53b1c1e1461022d578063a67808571461023e578063b61c05031461024c578063c2b12a731461025a578063d2282dc51461026b578063e30081a01461027c578063e8beef5b1461028d578063f38b06001461029b578063f5b53e17146102a9578063fd408767146102bb57005b6101346104d6565b60006000f35b61014261039b565b8060005260206000f35b610157600435610326565b60006000f35b6101686004356102c9565b60006000f35b610176610442565b8060005260206000f35b6101886103d3565b8060ff1660005260206000f35b61019d610413565b8073ffffffffffffffffffffffffffffffffffffffff1660005260206000f35b6101c56104c5565b60006000f35b6101d36103b7565b8060000b60005260206000f35b6101e8610454565b60006000f35b6101f6610401565b8060005260206000f35b61020861051f565b60006000f35b6102196004356102e5565b60006000f35b610227610693565b60006000f35b610238600435610342565b60006000f35b610246610484565b60006000f35b610254610493565b60006000f35b61026560043561038d565b60006000f35b610276600435610350565b60006000f35b61028760043561035e565b60006000f35b6102956105b4565b60006000f35b6102a3610547565b60006000f35b6102b16103ef565b8060005260206000f35b6102c3610600565b60006000f35b80600060006101000a81548160ff021916908302179055505b50565b80600060016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b50565b80600060026101000a81548160ff021916908302179055505b50565b806001600050819055505b50565b806002600050819055505b50565b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b50565b806004600050819055505b50565b6000600060009054906101000a900460ff1690506103b4565b90565b6000600060019054906101000a900460000b90506103d0565b90565b6000600060029054906101000a900460ff1690506103ec565b90565b600060016000505490506103fe565b90565b60006002600050549050610410565b90565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905061043f565b90565b60006004600050549050610451565b90565b7f65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be5806000602a81526020016000a15b565b6000602a81526020016000a05b565b60017f81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b6000602a81526020016000a25b565b60016000602a81526020016000a15b565b3373ffffffffffffffffffffffffffffffffffffffff1660017f0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b6000602a81526020016000a35b565b3373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a25b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017f317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f6000602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660016000602a81526020016000a35b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff1660017fd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a45b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6001023373ffffffffffffffffffffffffffffffffffffffff16600160007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe98152602001602a81526020016000a35b56", - "gasLimit" : "3141592", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getBool", - "data" : "0x12a7b914", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getInt8", - "data" : "0x57cb2fc4", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "2", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getUint8", - "data" : "0x343a875d", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "3", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "3141592", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "bcde5374fce5edbc8e2a8697c15331677e6ebf0b", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "3141592", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - }, - { - "transactions" : [ - { - "data" : "getInt256", - "data" : "0xf5b53e17", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "4", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getUint256", - "data" : "0x68895979", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "5", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getAddress", - "data" : "0x38cc4831", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "6", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getBytes32", - "data" : "0x1f903037", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "7", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setBool", - "data" : "0x1e26fd330000000000000000000000000000000000000000000000000000000000000001", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "8", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setBool", - "data" : "0x1e26fd330000000000000000000000000000000000000000000000000000000000000001", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "9", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setInt8", - "data" : "0x9a19a953fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "10", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setUint8", - "data" : "0x1774e6460000000000000000000000000000000000000000000000000000000000000008", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "11", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setInt256", - "data" : "0xa53b1c1effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "12", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setUint256", - "data" : "0xd2282dc5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "13", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setAddress", - "data" : "0xe30081a0aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "14", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "setBytes32", - "data" : "0xc2b12a73aabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "15", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getInt8", - "data" : "0x57cb2fc4", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "16", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getUint8", - "data" : "0x343a875d", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "17", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getInt256", - "data" : "0xf5b53e17", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "18", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getUint256", - "data" : "0x68895979", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "19", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getAddress", - "data" : "0x38cc4831", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "20", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "getBytes32", - "data" : "0x1f903037", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "21", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log0", - "data" : "0x65538c73", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "22", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log0a", - "data" : "0xa6780857", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "23", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log1", - "data" : "0xb61c0503", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "24", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log1a", - "data" : "0x4e7ad367", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "25", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log2", - "data" : "0x102accc1", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "26", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log2a", - "data" : "0x76bc21d9", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "27", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log3", - "data" : "0xf38b0600", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "28", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log3a", - "data" : "0xe8beef5b", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "29", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log4", - "data" : "0xfd408767", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "30", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "log4a", - "data" : "0x9dc2c8f5", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "31", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "6295ee1b4f6dd65047762f924ecd367c17eabf8f", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - } - ] - } -} -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 7471709ee081b6b4ffd1f324f2c755359151600d Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 23 Apr 2015 12:32:05 +0200 Subject: Squashed 'libjsqrc/ethereumjs/' changes from 4def095..f8a43ed f8a43ed Merge pull request #180 from ethereum/develop 4dc6e23 realease version 0.3.1 ee0ec4b Merge branch 'master' of github.com:ethereum/web3.js into develop 08dc2b2 add missing inputBlockNumberFormatter 99e89a1 Merge pull request #179 from ethereum/latest_pending dfbad66 add pending and latest to getBlockTransactionCount and getUncle dbf3ff0 latest and pending as possible blockNumber arg everywhere 3897bc2 version 0.3.0 d2068eb improved solidity event decoding 11f23ce Merge pull request #178 from ethereum/stringTopics 50f4a2b add new test filter 40c5c9e merged develop c9cd31b add test for the new toTopic filter e21ee7a Merge pull request #174 from ethereum/events_refactor 960e9c9 test for explicit sendTransaction && call a6ac6ed add new toTopic formatter in filters 3d3db61 tests for decoding event logs 7c16dbf one additional test for event encode 9f7d6a9 anonymous events implementation && tests b5eabd8 proper formatting event options 93b323f removed unused function findIndex from utils 9158ac7 removed unused function 1ac1ef9 cleaned event.encode test 5f2eb33 fixed filters encoding null 4482d5b Merge branch 'develop' into events_refactor 76ced9a basic tests for event encoding f767a9a removed unused formatOutputHash, renamed formatXXXString to formatXXXBytes 888a970 coder.encodeParam, coder.decodeParam tests template 983e4b1 removed signature.js f37057e Merge branch 'develop' of github.com:ethereum/web3.js into develop c8f4226 add possible 2d topic arrays fixes #175 e910736 eth_filter complex topics, #175 836529a Merge branch 'develop' into events_refactor 42e759e 0.10 on travis is painfully slow, lets remove it d411492 call && sendTransaction f84a68c changed the way functions are being called c8e5768 fixed log fields d38f5a2 Merge branch 'develop' into events_refactor a5c1bcc changed default providor port to 8545 closes #160 9e8cb8d removed non existing eth.flush method eeb0bc0 Merge branch 'develop' into events_refactor cdf02ec Merge pull request #173 from ethereum/failing_develop 501e3bc utils cleanup a88be00 docs 9d8a51d event.js refactored ea6bda4 event refactor in progress a827076 fixed tx/block return value tests 99a3696 events refactor, function.js 04cdb6c format also tx nonce to number 385cc2c removed minGasPrice from blocks c06d75b Merge pull request #170 from ethereum/abi_refactor e80ff10 Merge branch 'master' into abi_refactor 38641df fixed #154 1c8cd7d web3.eth.defaultAccount property, updated event_inc example, fixed #96 4aeba40 fixed event_inc example 5362e2a Merge branch 'develop' into abi_refactor 2a11852 Merge branch 'master' into develop ea413a8 updated gitter badge a46b9ea Merge branch 'develop' into abi_refactor 779a608 documentation 941535f SolidityParam moved to its own file && documented 18cef7c removed *collapse in contrat, gulp 677bb68 add bundle version 135b044 Merge pull request #164 from karalabe/empty-topics-fix b326202 formatters/whisper: polish corner case handling code 0567ba1 outputParser do not require 0x prefix before hash b5c6aa6 little cleanup && renaming dccfca1 solidity abi refactor in progress 6a058b6 Allow unset topics in posts too. af443f2 Fix #162: allow empty topic list in messages d643d06 solidity abi refactor in progress 271b00f bumped version f4cf699 rebuild 4eeaf19 rebuild 20fb2e3 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop ac69640 Merge pull request #158 from ethereum/watchImprovement2 96b4468 fixed #161, web3.ssh.post a320ef8 fixed coverage, unified creating errors 364eab7 add callback for async error c62f817 picked watch change3 56d13f7 picked watch change2 2215e7c picked watch change dc0f231 merged meteor package fixes c89ad86 renamed meteor package a0709f3 fixed meteor package 1a8032c version 0.2.7 dfb8dea gulp b1ada8d gulp a25a9e1 Merge branch 'master' of https://github.com/ethereum/ethereum.js 05343ea use version of bignumber.js without lookaheads 2651fd8 Update README.md git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: f8a43eddfb450d0e0ba1669a6916babe0ea43642 --- abi.inputParser.js | 14 +-- abi.outputParser.js | 96 +++++++------- coder.decodeParam.js | 20 +++ coder.encodeParam.js | 20 +++ contract.js | 98 ++++++++++++++- event.decode.js | 180 +++++++++++++++++++++++++++ event.encode.js | 206 +++++++++++++++++++++++++++++++ event.inputParser.js | 113 ----------------- event.outputParser.js | 81 ------------ formatters.inputPostFormatter.js | 3 +- formatters.outputBlockFormatter.js | 5 +- formatters.outputTransactionFormatter.js | 2 + helpers/test.method.js | 23 +++- method.validateArgs.js | 4 +- shh.filter.js | 45 ------- signature.js | 48 ------- utils.filters.js | 49 -------- web3.eth.contract.js | 2 +- web3.eth.getBlock.js | 8 +- web3.eth.getTransaction.js | 4 +- web3.eth.getTransactionFromBlock.js | 4 +- web3.eth.getUncle.js | 8 +- web3.shh.filter.js | 84 +++++++++++++ web3.shh.post.js | 49 ++++++++ 24 files changed, 741 insertions(+), 425 deletions(-) create mode 100644 coder.decodeParam.js create mode 100644 coder.encodeParam.js create mode 100644 event.decode.js create mode 100644 event.encode.js delete mode 100644 event.inputParser.js delete mode 100644 event.outputParser.js delete mode 100644 shh.filter.js delete mode 100644 signature.js delete mode 100644 utils.filters.js create mode 100644 web3.shh.filter.js create mode 100644 web3.shh.post.js diff --git a/abi.inputParser.js b/abi.inputParser.js index 7dc50b53..6700acd7 100644 --- a/abi.inputParser.js +++ b/abi.inputParser.js @@ -469,10 +469,10 @@ describe('lib/solidity/abi', function () { var parser = abi.inputParser(d); // then - assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000"); - assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000"); - assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000"); - assert.equal(parser.test([-1]), "ffffffffffffffffffffffffffffffff00000000000000000000000000000000"); + assert.equal(parser.test(1), "0000000000000000000000000000000100000000000000000000000000000000"); + assert.equal(parser.test(2.125), "0000000000000000000000000000000220000000000000000000000000000000"); + assert.equal(parser.test(8.5), "0000000000000000000000000000000880000000000000000000000000000000"); + assert.equal(parser.test(-1), "ffffffffffffffffffffffffffffffff00000000000000000000000000000000"); }); @@ -489,9 +489,9 @@ describe('lib/solidity/abi', function () { var parser = abi.inputParser(d); // then - assert.equal(parser.test([1]), "0000000000000000000000000000000100000000000000000000000000000000"); - assert.equal(parser.test([2.125]), "0000000000000000000000000000000220000000000000000000000000000000"); - assert.equal(parser.test([8.5]), "0000000000000000000000000000000880000000000000000000000000000000"); + assert.equal(parser.test(1), "0000000000000000000000000000000100000000000000000000000000000000"); + assert.equal(parser.test(2.125), "0000000000000000000000000000000220000000000000000000000000000000"); + assert.equal(parser.test(8.5), "0000000000000000000000000000000880000000000000000000000000000000"); }); diff --git a/abi.outputParser.js b/abi.outputParser.js index a57b84a8..5fe23e28 100644 --- a/abi.outputParser.js +++ b/abi.outputParser.js @@ -35,13 +35,13 @@ describe('lib/solidity/abi', function() { // then assert.equal( - parser.test("0x" + + parser.test( "0000000000000000000000000000000000000000000000000000000000000005" + "68656c6c6f000000000000000000000000000000000000000000000000000000")[0], 'hello' ); assert.equal( - parser.test("0x" + + parser.test( "0000000000000000000000000000000000000000000000000000000000000005" + "776f726c64000000000000000000000000000000000000000000000000000000")[0], 'world' @@ -62,14 +62,14 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000a")[0], 10); assert.equal( - parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10), + parser.test("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10), new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10) ); assert.equal( - parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10), + parser.test("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10), new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10) ); }); @@ -87,14 +87,14 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000a")[0], 10); assert.equal( - parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10), + parser.test("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10), new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10) ); assert.equal( - parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10), + parser.test("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10), new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10) ); }); @@ -112,14 +112,14 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000a")[0], 10); assert.equal( - parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10), + parser.test("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0].toString(10), new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).toString(10) ); assert.equal( - parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10), + parser.test("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0].toString(10), new BigNumber("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0", 16).toString(10) ); }); @@ -137,10 +137,10 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10); - assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1); - assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000a")[0], 10); + assert.equal(parser.test("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1); + assert.equal(parser.test("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); }); it('should parse output int256', function() { @@ -156,10 +156,10 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10); - assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1); - assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000a")[0], 10); + assert.equal(parser.test("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1); + assert.equal(parser.test("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); }); it('should parse output int128', function() { @@ -175,10 +175,10 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test("0x000000000000000000000000000000000000000000000000000000000000000a")[0], 10); - assert.equal(parser.test("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1); - assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test("000000000000000000000000000000000000000000000000000000000000000a")[0], 10); + assert.equal(parser.test("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")[0], -1); + assert.equal(parser.test("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); }); it('should parse output address', function() { @@ -195,7 +195,7 @@ describe('lib/solidity/abi', function() { // then assert.equal( - parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0], + parser.test("000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0], "0x407d73d8a49eeb85d32cf465507dd71d507100c1" ); }); @@ -213,8 +213,8 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000001")[0], true); - assert.equal(parser.test("0x0000000000000000000000000000000000000000000000000000000000000000")[0], false); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], true); + assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000000")[0], false); }); @@ -232,10 +232,10 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1); - assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125); - assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5); - assert.equal(parser.test("0xffffffffffffffffffffffffffffffff00000000000000000000000000000000")[0], -1); + assert.equal(parser.test("0000000000000000000000000000000100000000000000000000000000000000")[0], 1); + assert.equal(parser.test("0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125); + assert.equal(parser.test("0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5); + assert.equal(parser.test("ffffffffffffffffffffffffffffffff00000000000000000000000000000000")[0], -1); }); @@ -252,9 +252,9 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x0000000000000000000000000000000100000000000000000000000000000000")[0], 1); - assert.equal(parser.test("0x0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125); - assert.equal(parser.test("0x0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5); + assert.equal(parser.test("0000000000000000000000000000000100000000000000000000000000000000")[0], 1); + assert.equal(parser.test("0000000000000000000000000000000220000000000000000000000000000000")[0], 2.125); + assert.equal(parser.test("0000000000000000000000000000000880000000000000000000000000000000")[0], 8.5); }); @@ -274,7 +274,7 @@ describe('lib/solidity/abi', function() { // then assert.equal( - parser.test("0x" + + parser.test( "0000000000000000000000000000000000000000000000000000000000000005" + "0000000000000000000000000000000000000000000000000000000000000005" + "68656c6c6f000000000000000000000000000000000000000000000000000000" + @@ -282,7 +282,7 @@ describe('lib/solidity/abi', function() { 'hello' ); assert.equal( - parser.test("0x" + + parser.test( "0000000000000000000000000000000000000000000000000000000000000005" + "0000000000000000000000000000000000000000000000000000000000000005" + "68656c6c6f000000000000000000000000000000000000000000000000000000" + @@ -305,8 +305,8 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.helloworld("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.helloworld['int']("0x0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.helloworld("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.helloworld['int']("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); }); @@ -330,8 +330,8 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); //then - assert.equal(parser.test("0000000000000000000000000000000000000000000000000000000000000001")[0], 1); - assert.equal(parser.test2("0x" + + assert.equal(parser.test("00000000000000000000000000000000000000000000000000000000000001")[0], 1); + assert.equal(parser.test2( "0000000000000000000000000000000000000000000000000000000000000005" + "68656c6c6f000000000000000000000000000000000000000000000000000000")[0], "hello" @@ -351,13 +351,13 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x" + + assert.equal(parser.test( "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000005" + "0000000000000000000000000000000000000000000000000000000000000006")[0][0], 5 ); - assert.equal(parser.test("0x" + + assert.equal(parser.test( "0000000000000000000000000000000000000000000000000000000000000002" + "0000000000000000000000000000000000000000000000000000000000000005" + "0000000000000000000000000000000000000000000000000000000000000006")[0][1], @@ -366,7 +366,7 @@ describe('lib/solidity/abi', function() { }); - it('should parse 0x value', function () { + it('should parse 0x0 value', function () { // given var d = clone(description); @@ -378,11 +378,11 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x")[0], 0); + assert.equal(parser.test("0x0")[0], 0); }); - it('should parse 0x value', function () { + it('should parse 0x0 value', function () { // given var d = clone(description); @@ -394,7 +394,7 @@ describe('lib/solidity/abi', function() { var parser = abi.outputParser(d); // then - assert.equal(parser.test("0x")[0], 0); + assert.equal(parser.test("0x0")[0], 0); }); diff --git a/coder.decodeParam.js b/coder.decodeParam.js new file mode 100644 index 00000000..6fbeb853 --- /dev/null +++ b/coder.decodeParam.js @@ -0,0 +1,20 @@ +var chai = require('chai'); +var assert = chai.assert; +var coder = require('../lib/solidity/coder'); + +var tests = [ + { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000001', expected: 1}, + { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000010', expected: 16}, + { type: 'int', value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: -1} +]; + +describe('lib/solidity/coder', function () { + describe('decodeParam', function () { + tests.forEach(function (test) { + it('should turn ' + test.value + ' to ' + test.expected, function () { + assert.equal(coder.decodeParam(test.type, test.value), test.expected); + }); + }); + }); +}); + diff --git a/coder.encodeParam.js b/coder.encodeParam.js new file mode 100644 index 00000000..52b0a04d --- /dev/null +++ b/coder.encodeParam.js @@ -0,0 +1,20 @@ +var chai = require('chai'); +var assert = chai.assert; +var coder = require('../lib/solidity/coder'); + +var tests = [ + { type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}, + { type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}, + { type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'} +]; + +describe('lib/solidity/coder', function () { + describe('encodeParam', function () { + tests.forEach(function (test) { + it('should turn ' + test.value + ' to ' + test.expected, function () { + assert.equal(coder.encodeParam(test.type, test.value), test.expected); + }); + }); + }); +}); + diff --git a/contract.js b/contract.js index fec9fc31..db9840c5 100644 --- a/contract.js +++ b/contract.js @@ -63,11 +63,27 @@ describe('web3.eth.contract', function () { assert.deepEqual(payload.params[0], { topics: [ sha3, - '0x1234567890123456789012345678901234567890' + '0x0000000000000000000000001234567890123456789012345678901234567890', + null ], address: '0x1234567890123456789012345678901234567890' }); - } else if (step === 2 && utils.isArray(payload)) { + } else if (step === 2) { + step = 3; + provider.injectResult([{ + address: address, + topics: [ + sha3, + '0x0000000000000000000000001234567890123456789012345678901234567890', + '0x0000000000000000000000000000000000000000000000000000000000000001' + ], + number: 2, + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000008' + }]); + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_getFilterLogs'); + } else if (step === 3 && utils.isArray(payload)) { provider.injectBatchResults([[{ address: address, topics: [ @@ -89,12 +105,16 @@ describe('web3.eth.contract', function () { var Contract = web3.eth.contract(desc); var contract = new Contract(address); + var res = 0; contract.Changed({from: address}).watch(function(err, result) { assert.equal(result.args.from, address); assert.equal(result.args.amount, 1); assert.equal(result.args.t1, 1); assert.equal(result.args.t2, 8); - done(); + res++; + if (res === 2) { + done(); + } }); }); @@ -187,7 +207,40 @@ describe('web3.eth.contract', function () { var Contract = web3.eth.contract(desc); var contract = new Contract(address); - contract.call({from: address, gas: 50000}).balance(address); + contract.balance(address, {from: address, gas: 50000}); + + }); + + it('should explicitly make a call with optional params', function () { + + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + web3.reset(); + var sha3 = '0x5131231231231231231231'; + var address = '0x1234567890123456789012345678901234567890'; + provider.injectResult(sha3); + var step = 0; + provider.injectValidation(function (payload) { + if (step === 0) { + step = 1; + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'web3_sha3'); + assert.equal(payload.params[0], web3.fromAscii('balance(address)')); + } else if (step === 1) { + assert.equal(payload.method, 'eth_call'); + assert.deepEqual(payload.params, [{ + data: sha3.slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567890', + to: address, + from: address, + gas: '0xc350' + }, 'latest']); + } + }); + + var Contract = web3.eth.contract(desc); + var contract = new Contract(address); + + contract.balance.call(address, {from: address, gas: 50000}); }); @@ -223,7 +276,42 @@ describe('web3.eth.contract', function () { var Contract = web3.eth.contract(desc); var contract = new Contract(address); - contract.sendTransaction({from: address, gas: 50000, gasPrice: 3000, value: 10000}).send(address, 17); + contract.send(address, 17, {from: address, gas: 50000, gasPrice: 3000, value: 10000}); + }); + + it('should explicitly sendTransaction with optional params', function () { + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + web3.reset(); + var sha3 = '0x5131231231231231231231'; + var address = '0x1234567890123456789012345678901234567890'; + provider.injectResult(sha3); + var step = 0; + provider.injectValidation(function (payload) { + if (step === 0) { + step = 1; + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'web3_sha3'); + assert.equal(payload.params[0], web3.fromAscii('send(address,uint256)')); + } else if (step === 1) { + assert.equal(payload.method, 'eth_sendTransaction'); + assert.deepEqual(payload.params, [{ + data: sha3.slice(0, 10) + + '0000000000000000000000001234567890123456789012345678901234567890' + + '0000000000000000000000000000000000000000000000000000000000000011' , + to: address, + from: address, + gas: '0xc350', + gasPrice: '0xbb8', + value: '0x2710' + }]); + } + }); + + var Contract = web3.eth.contract(desc); + var contract = new Contract(address); + + contract.send.sendTransaction(address, 17, {from: address, gas: 50000, gasPrice: 3000, value: 10000}); }); }); }); diff --git a/event.decode.js b/event.decode.js new file mode 100644 index 00000000..971c4401 --- /dev/null +++ b/event.decode.js @@ -0,0 +1,180 @@ +var chai = require('chai'); +var assert = chai.assert; +var BigNumber = require('bignumber.js'); +var SolidityEvent = require('../lib/web3/event'); + +var name = 'event1'; +var address = '0x1234567890123456789012345678901234567890'; + +var tests = [{ + abi: { + name: name, + inputs: [] + }, + data: { + logIndex: '0x1', + transactionIndex: '0x10', + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: '0x1' + }, + expected: { + event: name, + args: {}, + logIndex: 1, + transactionIndex: 16, + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: 1 + } +}, { + abi: { + name: name, + inputs: [{ + name: 'a', + type: 'int', + indexed: false + }] + }, + data: { + logIndex: '0x1', + transactionIndex: '0x10', + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: '0x1', + data: '0x0000000000000000000000000000000000000000000000000000000000000001' + }, + expected: { + event: name, + args: { + a: new BigNumber(1) + }, + logIndex: 1, + transactionIndex: 16, + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: 1 + } +}, { + abi: { + name: name, + inputs: [{ + name: 'a', + type: 'int', + indexed: false + }, { + name: 'b', + type: 'int', + indexed: true + }, { + name: 'c', + type: 'int', + indexed: false + }, { + name: 'd', + type: 'int', + indexed: true + }] + }, + data: { + logIndex: '0x1', + transactionIndex: '0x10', + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: '0x1', + data: '0x' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000004', + topics: [ + address, + '0x000000000000000000000000000000000000000000000000000000000000000a', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] + }, + expected: { + event: name, + args: { + a: new BigNumber(1), + b: new BigNumber(10), + c: new BigNumber(4), + d: new BigNumber(16) + }, + logIndex: 1, + transactionIndex: 16, + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: 1 + } +}, { + abi: { + name: name, + anonymous: true, + inputs: [{ + name: 'a', + type: 'int', + indexed: false + }, { + name: 'b', + type: 'int', + indexed: true + }, { + name: 'c', + type: 'int', + indexed: false + }, { + name: 'd', + type: 'int', + indexed: true + }] + }, + data: { + logIndex: '0x1', + transactionIndex: '0x10', + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: '0x1', + data: '0x' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000004', + topics: [ + '0x000000000000000000000000000000000000000000000000000000000000000a', + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] + }, + expected: { + event: name, + args: { + a: new BigNumber(1), + b: new BigNumber(10), + c: new BigNumber(4), + d: new BigNumber(16) + }, + logIndex: 1, + transactionIndex: 16, + transactionHash: '0x1234567890', + address: address, + blockHash: '0x1234567890', + blockNumber: 1 + } +}]; + +describe('lib/web3/event', function () { + describe('decode', function () { + tests.forEach(function (test, index) { + it('test no: ' + index, function () { + var event = new SolidityEvent(test.abi, address); + + var result = event.decode(test.data); + assert.deepEqual(result, test.expected); + }); + }); + }); +}); + diff --git a/event.encode.js b/event.encode.js new file mode 100644 index 00000000..c28588c2 --- /dev/null +++ b/event.encode.js @@ -0,0 +1,206 @@ +var chai = require('chai'); +var assert = chai.assert; +var SolidityEvent = require('../lib/web3/event'); + +var address = '0x1234567890123456789012345678901234567890'; +var signature = '0xffff'; + +var tests = [{ + abi: { + name: 'event1', + inputs: [] + }, + indexed: {}, + options: {}, + expected: { + address: address, + topics: [ + signature + ] + } +}, { + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }] + }, + indexed: { + a: 16 + }, + options: {}, + expected: { + address: address, + topics: [ + signature, + '0x0000000000000000000000000000000000000000000000000000000000000010' + ] + } +},{ + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }, { + type: 'int', + name: 'b', + indexed: true + }, { + type: 'int', + name: 'c', + indexed: false + }, { + type: 'int', + name: 'd', + indexed: true + }] + }, + indexed: { + b: 4 + }, + options: {}, + expected: { + address: address, + topics: [ + signature, // signature + null, // a + '0x0000000000000000000000000000000000000000000000000000000000000004', // b + null // d + ] + } +}, { + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }, { + type: 'int', + name: 'b', + indexed: true + }] + }, + indexed: { + a: [16, 1], + b: 2 + }, + options: {}, + expected: { + address: address, + topics: [ + signature, + ['0x0000000000000000000000000000000000000000000000000000000000000010', '0x0000000000000000000000000000000000000000000000000000000000000001'], + '0x0000000000000000000000000000000000000000000000000000000000000002' + ] + } +}, { + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }] + }, + indexed: { + a: null + }, + options: {}, + expected: { + address: address, + topics: [ + signature, + null + ] + } +}, { + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }] + }, + indexed: { + a: 1 + }, + options: { + fromBlock: 4, + toBlock: 10 + }, + expected: { + address: address, + fromBlock: '0x4', + toBlock: '0xa', + topics: [ + signature, + '0x0000000000000000000000000000000000000000000000000000000000000001' + ] + } +}, { + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }], + anonymous: true + }, + indexed: { + a: 1 + }, + options: {}, + expected: { + topics: [ + '0x0000000000000000000000000000000000000000000000000000000000000001' + ] + } +}, { + abi: { + name: 'event1', + inputs: [{ + type: 'int', + name: 'a', + indexed: true + }, { + type: 'int', + name: 'b', + indexed: true + }], + anonymous: true + }, + indexed: { + b: 1 + }, + options: {}, + expected: { + topics: [ + null, + '0x0000000000000000000000000000000000000000000000000000000000000001' + ] + } +}]; + +describe('lib/web3/event', function () { + describe('encode', function () { + tests.forEach(function (test, index) { + it('test no: ' + index, function () { + var event = new SolidityEvent(test.abi, address); + event.signature = function () { // inject signature + return signature.slice(2); + }; + + var result = event.encode(test.indexed, test.options); + assert.deepEqual(result, test.expected); + }); + }); + }); +}); + diff --git a/event.inputParser.js b/event.inputParser.js deleted file mode 100644 index 15e0b6d2..00000000 --- a/event.inputParser.js +++ /dev/null @@ -1,113 +0,0 @@ -var assert = require('assert'); -var event = require('../lib/web3/event.js'); -var f = require('../lib/solidity/formatters.js'); - -describe('lib/web3/event', function () { - describe('inputParser', function () { - it('should create basic filter input object', function () { - - // given - var address = '0x012345'; - var signature = '0x987654'; - var e = { - name: 'Event', - inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}] - }; - - // when - var impl = event.inputParser(address, signature, e); - var result = impl(); - - // then - assert.equal(result.address, address); - assert.equal(result.topics.length, 1); - assert.equal(result.topics[0], signature); - - }); - - it('should create filter input object with options', function () { - - // given - var address = '0x012345'; - var signature = '0x987654'; - var options = { - fromBlock: 1, - toBlock: 2, - }; - var e = { - name: 'Event', - inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}] - }; - - // when - var impl = event.inputParser(address, signature, e); - var result = impl({}, options); - - // then - assert.equal(result.address, address); - assert.equal(result.topics.length, 1); - assert.equal(result.topics[0], signature); - assert.equal(result.fromBlock, options.fromBlock); - assert.equal(result.toBlock, options.toBlock); - - }); - - it('should create filter input object with indexed params', function () { - - // given - var address = '0x012345'; - var signature = '0x987654'; - var options = { - fromBlock: 1, - toBlock: 2 - }; - var e = { - name: 'Event', - inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}] - }; - - // when - var impl = event.inputParser(address, signature, e); - var result = impl({a: 4}, options); - - // then - assert.equal(result.address, address); - assert.equal(result.topics.length, 2); - assert.equal(result.topics[0], signature); - assert.equal(result.topics[1], '0x' + f.formatInputInt(4)); - assert.equal(result.fromBlock, options.fromBlock); - assert.equal(result.toBlock, options.toBlock); - - }); - - it('should create filter input object with an array of indexed params', function () { - - // given - var address = '0x012345'; - var signature = '0x987654'; - var options = { - fromBlock: 1, - toBlock: 2, - }; - var e = { - name: 'Event', - inputs: [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}] - }; - - // when - var impl = event.inputParser(address, signature, e); - var result = impl({a: [4, 69]}, options); - - // then - assert.equal(result.address, address); - assert.equal(result.topics.length, 2); - assert.equal(result.topics[0], signature); - assert.equal(result.topics[1][0], f.formatInputInt(4)); - assert.equal(result.topics[1][1], f.formatInputInt(69)); - assert.equal(result.fromBlock, options.fromBlock); - assert.equal(result.toBlock, options.toBlock); - - }); - }); -}); - diff --git a/event.outputParser.js b/event.outputParser.js deleted file mode 100644 index d31e49fa..00000000 --- a/event.outputParser.js +++ /dev/null @@ -1,81 +0,0 @@ -var assert = require('assert'); -var event = require('../lib/web3/event.js'); - -describe('lib/web3/event', function () { - describe('outputParser', function () { - it('should parse basic event output object', function () { - - // given - var output = { - "address":"0x78dfc5983baecf65f73e3de3a96cee24e6b7981e", - "data":"0x000000000000000000000000000000000000000000000000000000000000004b", - "number":2, - "topics":[ - "0x6e61ef44ac2747ff8b84d353a908eb8bd5c3fb118334d57698c5cfc7041196ad", - "0x0000000000000000000000000000000000000000000000000000000000000001" - ] - }; - - var e = { - name: 'Event', - inputs: [{"name":"a","type":"bool","indexed":true},{"name":"b","type":"uint256","indexed":false}] - }; - - // when - var impl = event.outputParser(e); - var result = impl(output); - - // then - assert.equal(result.event, 'Event'); - assert.equal(result.number, 2); - assert.equal(Object.keys(result.args).length, 2); - assert.equal(result.args.a, true); - assert.equal(result.args.b, 75); - }); - - it('should parse event output object arguments in correct order', function () { - - // given - var output = { - "address":"0x78dfc5983baecf65f73e3de3a96cee24e6b7981e", - "data": "0x" + - "000000000000000000000000000000000000000000000000000000000000004b" + - "000000000000000000000000000000000000000000000000000000000000004c" + - "0000000000000000000000000000000000000000000000000000000000000001", - "number":3, - "topics":[ - "0x6e61ef44ac2747ff8b84d353a908eb8bd5c3fb118334d57698c5cfc7041196ad", - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000005" - ] - }; - - var e = { - name: 'Event2', - inputs: [ - {"name":"a","type":"bool","indexed":true}, - {"name":"b","type":"int","indexed":false}, - {"name":"c","type":"int","indexed":false}, - {"name":"d","type":"int","indexed":true}, - {"name":"e","type":"bool","indexed":false} - ] - }; - - // when - var impl = event.outputParser(e); - var result = impl(output); - - // then - assert.equal(result.event, 'Event2'); - assert.equal(result.number, 3); - assert.equal(Object.keys(result.args).length, 5); - assert.equal(result.args.a, true); - assert.equal(result.args.b, 75); - assert.equal(result.args.c, 76); - assert.equal(result.args.d, 5); - assert.equal(result.args.e, true); - - }); - }); -}); - diff --git a/formatters.inputPostFormatter.js b/formatters.inputPostFormatter.js index 7f0ce529..705a93bc 100644 --- a/formatters.inputPostFormatter.js +++ b/formatters.inputPostFormatter.js @@ -20,7 +20,8 @@ describe('formatters', function () { payload: '0x7b2274657374223a2274657374227d', ttl: '0xc8', priority: '0x3e8', - topics: ['0x68656c6c6f','0x6d79746f70696373'] + topics: ['0x68656c6c6f','0x6d79746f70696373'], + workToProve: '0x0' }); }); diff --git a/formatters.outputBlockFormatter.js b/formatters.outputBlockFormatter.js index f31cced9..27225065 100644 --- a/formatters.outputBlockFormatter.js +++ b/formatters.outputBlockFormatter.js @@ -1,4 +1,5 @@ -var assert = require('assert'); +var chai = require('chai'); +var assert = chai.assert; var formatters = require('../lib/web3/formatters.js'); var BigNumber = require('bignumber.js'); @@ -16,7 +17,6 @@ describe('formatters', function () { difficulty: '0x3e8', totalDifficulty: '0x3e8', number: '0x3e8', - minGasPrice: '0x3e8', gasLimit: '0x3e8', gasUsed: '0x3e8', timestamp: '0x3e8', @@ -34,7 +34,6 @@ describe('formatters', function () { difficulty: new BigNumber(1000), totalDifficulty: new BigNumber(1000), number: 1000, - minGasPrice: new BigNumber(1000), gasLimit: 1000, gasUsed: 1000, timestamp: 1000, diff --git a/formatters.outputTransactionFormatter.js b/formatters.outputTransactionFormatter.js index b1eaff52..ef19b6da 100644 --- a/formatters.outputTransactionFormatter.js +++ b/formatters.outputTransactionFormatter.js @@ -13,6 +13,7 @@ describe('formatters', function () { value: '0x3e8', gas: '0x3e8', gasPrice: '0x3e8', + nonce: '0xb', transactionIndex: '0x1', blockNumber: '0x3e8', blockHash: '0x34234bf23bf4234' @@ -23,6 +24,7 @@ describe('formatters', function () { value: new BigNumber(1000), gas: 1000, gasPrice: new BigNumber(1000), + nonce: 11, blockNumber: 1000, blockHash: '0x34234bf23bf4234', transactionIndex: 1 diff --git a/helpers/test.method.js b/helpers/test.method.js index 8de318d8..70068c0f 100644 --- a/helpers/test.method.js +++ b/helpers/test.method.js @@ -2,6 +2,7 @@ var chai = require('chai'); var assert = chai.assert; var web3 = require('../../index'); var FakeHttpProvider = require('./FakeHttpProvider'); +var clone = function (object) { return JSON.parse(JSON.stringify(object)); }; var runTests = function (obj, method, tests) { @@ -22,10 +23,18 @@ var runTests = function (obj, method, tests) { assert.deepEqual(payload.params, test.formattedArgs); }); + var args = clone(test.args) + + // when + if (obj) { + var result = web3[obj][method].apply(null, args); + } else { + var result = web3[method].apply(null, args); + } // when - var result = (obj) - ? web3[obj][method].apply(null, test.args.slice(0)) - : web3[method].apply(null, test.args.slice(0)); + //var result = (obj) + //? web3[obj][method].apply(null, test.args.slice(0)) + //: web3[method].apply(null, test.args.slice(0)); // then assert.deepEqual(test.formattedResult, result); @@ -43,7 +52,8 @@ var runTests = function (obj, method, tests) { assert.deepEqual(payload.params, test.formattedArgs); }); - var args = test.args.slice(0); + var args = clone(test.args); + // add callback args.push(function (err, result) { assert.deepEqual(test.formattedResult, result); @@ -51,10 +61,11 @@ var runTests = function (obj, method, tests) { }); // when - if(obj) + if (obj) { web3[obj][method].apply(null, args); - else + } else { web3[method].apply(null, args); + } }); }); }); diff --git a/method.validateArgs.js b/method.validateArgs.js index 5cb16e1e..cd4882ce 100644 --- a/method.validateArgs.js +++ b/method.validateArgs.js @@ -39,8 +39,8 @@ describe('lib/web3/method', function () { var test2 = function () { method.validateArgs(args2); }; // then - assert.throws(test, errors.InvalidNumberOfParams); - assert.throws(test2, errors.InvalidNumberOfParams); + assert.throws(test, errors.InvalidNumberOfParams().message); + assert.throws(test2, errors.InvalidNumberOfParams().message); }); }); }); diff --git a/shh.filter.js b/shh.filter.js deleted file mode 100644 index 57df4d0c..00000000 --- a/shh.filter.js +++ /dev/null @@ -1,45 +0,0 @@ -var chai = require('chai'); -var web3 = require('../index'); -var assert = chai.assert; -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); - -var method = 'filter'; - -var tests = [{ - args: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', '0x564b4566f3453'] - }], - formattedArgs: [{ - to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', - topics: ['0x324f5435', '0x564b4566f3453'] - }], - result: '0xf', - formattedResult: '0xf', - call: 'shh_newFilter' -}]; - -describe('shh', function () { - describe(method, function () { - tests.forEach(function (test, index) { - it('property test: ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.method, test.call); - assert.deepEqual(payload.params, test.formattedArgs); - }); - - // call - web3.shh[method].apply(null, test.args); - - }); - }); - }); -}); - - diff --git a/signature.js b/signature.js deleted file mode 100644 index 709f662f..00000000 --- a/signature.js +++ /dev/null @@ -1,48 +0,0 @@ -var chai = require('chai'); -var assert = chai.assert; -var utils = require('../lib/utils/utils'); -var FakeHttpProvider = require('./helpers/FakeHttpProvider'); -var signature = require('../lib/web3/signature'); -var web3 = require('../index'); - -var tests = [{ - method: 'functionSignatureFromAscii', - call: 'web3_sha3', - request: 'multiply', - formattedRequest: utils.fromAscii('multiply'), - result: '0x255d31552d29a21e93334e96055c6dca7cd329f5420ae74ec166d0c47f9f9843', - formattedResult: '0x255d3155' -},{ - method: 'eventSignatureFromAscii', - call: 'web3_sha3', - request: 'multiply', - formattedRequest: utils.fromAscii('multiply'), - result: '0x255d31552d29a21e93334e96055c6dca7cd329f5420ae74ec166d0c47f9f9843', - formattedResult: '0x255d31552d29a21e93334e96055c6dca7cd329f5420ae74ec166d0c47f9f9843' -}]; - -describe('lib/web3/signature', function () { - tests.forEach(function (test, index) { - describe(test.method, function () { - it('should properly format and return signature of solidity functioni ' + index, function () { - - // given - var provider = new FakeHttpProvider(); - web3.setProvider(provider); - provider.injectResult(test.result); - provider.injectValidation(function (payload) { - assert.equal(payload.method, test.call); - assert.equal(payload.jsonrpc, '2.0'); - assert.equal(payload.params[0], test.formattedRequest); - }); - - // when - var result = signature[test.method].call(null, test.request); - - // then - assert.equal(result, test.formattedResult); - }); - }); - }); -}); - diff --git a/utils.filters.js b/utils.filters.js deleted file mode 100644 index 5f37b6f1..00000000 --- a/utils.filters.js +++ /dev/null @@ -1,49 +0,0 @@ -var assert = require('assert'); -var utils = require('../lib/solidity/utils'); - -describe('lib/utils/utils', function() { - it('should filter functions and events from input array properly', function () { - - // given - var description = [{ - "name": "test", - "type": "function", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ], - }, { - "name": "test2", - "type": "event", - "inputs": [{ - "name": "a", - "type": "uint256" - } - ], - "outputs": [ - { - "name": "d", - "type": "uint256" - } - ] - }]; - - // when - var events = utils.filterEvents(description); - var functions = utils.filterFunctions(description); - - // then - assert.equal(events.length, 1); - assert.equal(events[0].name, 'test2'); - assert.equal(functions.length, 1); - assert.equal(functions[0].name, 'test'); - - }); -}); diff --git a/web3.eth.contract.js b/web3.eth.contract.js index a657545d..651810b6 100644 --- a/web3.eth.contract.js +++ b/web3.eth.contract.js @@ -234,7 +234,7 @@ describe('web3.eth.contract', function() { }); var Con = contract(description); - var myCon = new Con(code, 2); + var myCon = new Con({data: code}, 2); }); }); diff --git a/web3.eth.getBlock.js b/web3.eth.getBlock.js index 539e433a..48926e89 100644 --- a/web3.eth.getBlock.js +++ b/web3.eth.getBlock.js @@ -19,7 +19,6 @@ var blockResult = { "size": "0x027f07", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x9f759", - "minGasPrice": "0x9f759", "gasUsed": "0x9f759", "timestamp": "0x54e34e8e", "transactions": ['0x460cfb8472af2c5fd05b5a2','0x460cfb8472af2c5fd05b5a2'], @@ -40,7 +39,6 @@ var formattedBlockResult = { "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, - "minGasPrice": new BigNumber(653145), "gasUsed": 653145, "timestamp": 1424182926, "transactions": ['0x460cfb8472af2c5fd05b5a2','0x460cfb8472af2c5fd05b5a2'], @@ -61,13 +59,12 @@ var blockResultWithTx = { "size": "0x027f07", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x9f759", - "minGasPrice": "0x9f759", "gasUsed": "0x9f759", "timestamp": "0x54e34e8e", "transactions": [{ "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce":"0x2", "blockHash": "0x6fd9e2a26ab", "blockNumber": "0x15df", "transactionIndex": "0x1", @@ -95,13 +92,12 @@ var formattedBlockResultWithTx = { "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, - "minGasPrice": new BigNumber(653145), "gasUsed": 653145, "timestamp": 1424182926, "transactions": [{ "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce": 2, "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, diff --git a/web3.eth.getTransaction.js b/web3.eth.getTransaction.js index fb833edf..b9ef034a 100644 --- a/web3.eth.getTransaction.js +++ b/web3.eth.getTransaction.js @@ -8,7 +8,7 @@ var method = 'getTransaction'; var txResult = { "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce":"0x5", "blockHash": "0x6fd9e2a26ab", "blockNumber": "0x15df", "transactionIndex": "0x1", @@ -22,7 +22,7 @@ var txResult = { var formattedTxResult = { "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce":5, "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, diff --git a/web3.eth.getTransactionFromBlock.js b/web3.eth.getTransactionFromBlock.js index 7b59a3ba..9f59a606 100644 --- a/web3.eth.getTransactionFromBlock.js +++ b/web3.eth.getTransactionFromBlock.js @@ -8,7 +8,7 @@ var method = 'getTransactionFromBlock'; var txResult = { "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce":"0xb", "blockHash": "0x6fd9e2a26ab", "blockNumber": "0x15df", "transactionIndex": "0x1", @@ -22,7 +22,7 @@ var txResult = { var formattedTxResult = { "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce":11, "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, diff --git a/web3.eth.getUncle.js b/web3.eth.getUncle.js index c5d723dc..4c5473c0 100644 --- a/web3.eth.getUncle.js +++ b/web3.eth.getUncle.js @@ -20,7 +20,6 @@ var blockResult = { "size": "0x027f07", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x9f759", - "minGasPrice": "0x9f759", "gasUsed": "0x9f759", "timestamp": "0x54e34e8e", "transactions": ['0x460cfb8472af2c5fd05b5a2','0x460cfb8472af2c5fd05b5a2'], @@ -41,7 +40,6 @@ var formattedBlockResult = { "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, - "minGasPrice": new BigNumber(653145), "gasUsed": 653145, "timestamp": 1424182926, "transactions": ['0x460cfb8472af2c5fd05b5a2','0x460cfb8472af2c5fd05b5a2'], @@ -62,13 +60,12 @@ var blockResultWithTx = { "size": "0x027f07", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x9f759", - "minGasPrice": "0x9f759", "gasUsed": "0x9f759", "timestamp": "0x54e34e8e", "transactions": [{ "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce":"0x2", "blockHash": "0x6fd9e2a26ab", "blockNumber": "0x15df", "transactionIndex": "0x1", @@ -96,13 +93,12 @@ var formattedBlockResultWithTx = { "size": 163591, "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": 653145, - "minGasPrice": new BigNumber(653145), "gasUsed": 653145, "timestamp": 1424182926, "transactions": [{ "status": "mined", "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", - "nonce":"0x", + "nonce": 2, "blockHash": "0x6fd9e2a26ab", "blockNumber": 5599, "transactionIndex": 1, diff --git a/web3.shh.filter.js b/web3.shh.filter.js new file mode 100644 index 00000000..05ec35a6 --- /dev/null +++ b/web3.shh.filter.js @@ -0,0 +1,84 @@ +var chai = require('chai'); +var web3 = require('../index'); +var assert = chai.assert; +var FakeHttpProvider = require('./helpers/FakeHttpProvider'); + +var method = 'filter'; + +var tests = [{ + args: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x324f5435', '0x564b4566f3453'] + }], + formattedArgs: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x324f5435', '0x564b4566f3453'] + }], + result: '0xf', + formattedResult: '0xf', + call: 'shh_newFilter' +}, +{ + args: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x324f5435', ['0x564b4566f3453', '0x345345343453']] + }], + formattedArgs: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x324f5435', ['0x564b4566f3453', '0x345345343453']] + }], + result: '0xf', + formattedResult: '0xf', + call: 'shh_newFilter' +}, +{ + args: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x324f5435', null, ['0x564b4566f3453', '0x345345343453']] + }], + formattedArgs: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x324f5435', null, ['0x564b4566f3453', '0x345345343453']] + }], + result: '0xf', + formattedResult: '0xf', + call: 'shh_newFilter' +}, +{ + args: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['myString', 11, '23', null] + }], + formattedArgs: [{ + to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855', + topics: ['0x6d79537472696e67', '0x3131', '0x3233', null] + }], + result: '0xf', + formattedResult: '0xf', + call: 'shh_newFilter' +}]; + +describe('shh', function () { + describe(method, function () { + tests.forEach(function (test, index) { + it('property test: ' + index, function () { + + // given + var provider = new FakeHttpProvider(); + web3.setProvider(provider); + provider.injectResult(test.result); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, test.call); + assert.deepEqual(payload.params, test.formattedArgs); + }); + + // call + web3.shh[method].apply(null, test.args); + + }); + }); + }); +}); + + diff --git a/web3.shh.post.js b/web3.shh.post.js new file mode 100644 index 00000000..89862b64 --- /dev/null +++ b/web3.shh.post.js @@ -0,0 +1,49 @@ +var chai = require('chai'); +var web3 = require('../index'); +var testMethod = require('./helpers/test.method.js'); + +var method = 'post'; + +var tests = [{ + args: [{ + from: '0x123123123', + topics: ['hello_world'], + payload: '12345', + ttl: 100, + workToProve: 101 + }], + formattedArgs: [{ + from: '0x123123123', + topics: [web3.fromAscii('hello_world')], + payload: web3.toHex('12345'), + ttl: web3.toHex('100'), + workToProve: web3.toHex('101'), + priority: '0x0' + }], + result: true, + formattedResult: true, + call: 'shh_'+ method +}, { + args: [{ + from: '0x21312', + topics: ['hello_world'], + payload: '0x12345', + ttl: 0x100, + workToProve: 0x101, + priority: 0x15 + }], + formattedArgs: [{ + from: '0x21312', + topics: [web3.fromAscii('hello_world')], + payload: '0x12345', + ttl: '0x100', + workToProve: '0x101', + priority: '0x15' + }], + result: true, + formattedResult: true, + call: 'shh_'+ method +}]; + +testMethod.runTests('shh', method, tests); + -- cgit v1.2.3 From 1a137629e31ac63d44fcdd72ddf454b1ce692354 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 24 Apr 2015 11:02:20 +0200 Subject: Squashed 'libjsqrc/ethereumjs/' changes from f8a43ed..c74c854 c74c854 version 0.3.2 9fa9cc7 fixed fixed size bytes encoding and decoding git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: c74c854b56cb76bfc941d7aef8a135b7c1cfc4b3 --- coder.decodeParam.js | 9 ++++++--- coder.encodeParam.js | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/coder.decodeParam.js b/coder.decodeParam.js index 6fbeb853..0a67bda0 100644 --- a/coder.decodeParam.js +++ b/coder.decodeParam.js @@ -3,9 +3,12 @@ var assert = chai.assert; var coder = require('../lib/solidity/coder'); var tests = [ - { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000001', expected: 1}, - { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000010', expected: 16}, - { type: 'int', value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: -1} + { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000001', expected: 1}, + { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000010', expected: 16}, + { type: 'int', value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: -1}, + { type: 'bytes32', value: '6761766f66796f726b0000000000000000000000000000000000000000000000', expected: 'gavofyork'}, + { type: 'bytes', value: '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000', expected: 'gavofyork'} ]; describe('lib/solidity/coder', function () { diff --git a/coder.encodeParam.js b/coder.encodeParam.js index 52b0a04d..1a4df06b 100644 --- a/coder.encodeParam.js +++ b/coder.encodeParam.js @@ -3,9 +3,12 @@ var assert = chai.assert; var coder = require('../lib/solidity/coder'); var tests = [ - { type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}, - { type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}, - { type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'} + { type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}, + { type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}, + { type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, + { type: 'bytes32', value: 'gavofyork', expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}, + { type: 'bytes', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'} ]; describe('lib/solidity/coder', function () { -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From bd08a2bbe23238edb3a25b0f345e8a38f3283e3a Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 21 Apr 2015 23:10:55 +0300 Subject: BlockWeight: tests refactoring --- TestHelper.cpp | 80 ++++++++++++++++++++++++++++++++++++++-------------------- TestHelper.h | 8 ++++++ 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 724bcaf6..8ea70ed1 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -137,7 +137,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o) str = value.get_str(); else continue; - _o[key] = (str.substr(0, 2) == "0x") ? str : "0x" + toHex(toCompactBigEndian(toInt(str), 1)); + _o[key] = (str.substr(0, 2) == "0x") ? str : jsonHex(toInt(str)); } return _o; } @@ -327,7 +327,7 @@ void ImportTest::checkExpectedState(State const& _stateExpect, State const& _sta void ImportTest::exportTest(bytes const& _output, State const& _statePost) { // export output - m_TestObject["out"] = "0x" + toHex(_output); + m_TestObject["out"] = jsonHex(_output); // export logs m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries()); @@ -344,7 +344,7 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) // export post state m_TestObject["post"] = fillJsonWithState(_statePost); - m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes()); + m_TestObject["postStateRoot"] = jsonHex(_statePost.rootHash().asBytes()); // export pre state m_TestObject["pre"] = fillJsonWithState(m_statePre); @@ -352,29 +352,72 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) m_TestObject["transaction"] = makeAllFieldsHex(m_TestObject["transaction"].get_obj()); } +std::string jsonHash(h256 const& _value) { return toString(_value); } +std::string jsonHash(Nonce const& _value) { return toString(_value); } +std::string jsonHash(LogBloom const& _value) { return toString(_value); } +std::string jsonHash(Address const& _value) { return toString(_value); } +std::string jsonHex(bytesConstRef _code) { return "0x" + toHex(_code); } +std::string jsonHex(bytes const& _code) { return "0x" + toHex(_code); } +std::string jsonHex(u256 const& _value, bool _nonempty) +{ + return "0x" + toHex(toCompactBigEndian(_value, _nonempty ? 1 : 0)); +} + +json_spirit::mObject fillJsonWithTransaction(Transaction _txn) +{ + json_spirit::mObject txObject; + txObject["nonce"] = jsonHex(_txn.nonce()); + txObject["data"] = jsonHex(_txn.data()); + txObject["gasLimit"] = jsonHex(_txn.gas()); + txObject["gasPrice"] = jsonHex(_txn.gasPrice()); + txObject["r"] = jsonHex(_txn.signature().r); + txObject["s"] = jsonHex(_txn.signature().s); + txObject["v"] = jsonHex(_txn.signature().v + 27); + txObject["to"] = _txn.isCreation() ? "" : jsonHash(_txn.receiveAddress()); + txObject["value"] = jsonHex(_txn.value()); + return txObject; +} + json_spirit::mObject fillJsonWithState(State _state) { - // export pre state json_spirit::mObject oState; - for (auto const& a: _state.addresses()) { json_spirit::mObject o; - o["balance"] = "0x" + toHex(toCompactBigEndian(_state.balance(a.first), 1)); - o["nonce"] = "0x" + toHex(toCompactBigEndian(_state.transactionsFrom(a.first), 1)); + o["balance"] = jsonHex(_state.balance(a.first)); + o["nonce"] = jsonHex(_state.transactionsFrom(a.first)); { json_spirit::mObject store; for (auto const& s: _state.storage(a.first)) - store["0x"+toHex(toCompactBigEndian(s.first))] = "0x"+toHex(toCompactBigEndian(s.second)); + store[jsonHex(s.first)] = jsonHex(s.second); o["storage"] = store; } - o["code"] = "0x" + toHex(_state.code(a.first)); + o["code"] = jsonHex(_state.code(a.first)); oState[toString(a.first)] = o; } return oState; } +json_spirit::mArray exportLog(eth::LogEntries _logs) +{ + json_spirit::mArray ret; + if (_logs.size() == 0) return ret; + for (LogEntry const& l: _logs) + { + json_spirit::mObject o; + o["address"] = jsonHash(l.address); + json_spirit::mArray topics; + for (auto const& t: l.topics) + topics.push_back(toString(t)); + o["topics"] = topics; + o["data"] = jsonHex(l.data); + o["bloom"] = jsonHash(l.bloom()); + ret.push_back(o); + } + return ret; +} + u256 toInt(json_spirit::mValue const& _v) { switch (_v.type()) @@ -455,25 +498,6 @@ LogEntries importLog(json_spirit::mArray& _a) return logEntries; } -json_spirit::mArray exportLog(eth::LogEntries _logs) -{ - json_spirit::mArray ret; - if (_logs.size() == 0) return ret; - for (LogEntry const& l: _logs) - { - json_spirit::mObject o; - o["address"] = toString(l.address); - json_spirit::mArray topics; - for (auto const& t: l.topics) - topics.push_back(toString(t)); - o["topics"] = topics; - o["data"] = "0x" + toHex(l.data); - o["bloom"] = toString(l.bloom()); - ret.push_back(o); - } - return ret; -} - void checkOutput(bytes const& _output, json_spirit::mObject& _o) { int j = 0; diff --git a/TestHelper.h b/TestHelper.h index bf4cdc16..1e09cf69 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -161,6 +161,14 @@ void userDefinedTest(std::string testTypeFlag, std::function void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs) -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 5d35f71350b925fbd4da999f8db1c811b3f3757d Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 23 Apr 2015 02:43:35 +0300 Subject: BlockWeight: toCompactHex refactoring --- TestHelper.cpp | 50 +++++++++++++++++++------------------------------- TestHelper.h | 7 ------- 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 8ea70ed1..0aa508c2 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -137,7 +137,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o) str = value.get_str(); else continue; - _o[key] = (str.substr(0, 2) == "0x") ? str : jsonHex(toInt(str)); + _o[key] = (str.substr(0, 2) == "0x") ? str : toHex(toInt(str), HexPrefix::Add); } return _o; } @@ -327,7 +327,7 @@ void ImportTest::checkExpectedState(State const& _stateExpect, State const& _sta void ImportTest::exportTest(bytes const& _output, State const& _statePost) { // export output - m_TestObject["out"] = jsonHex(_output); + m_TestObject["out"] = "0x" + toString(_output); // export logs m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries()); @@ -344,7 +344,7 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) // export post state m_TestObject["post"] = fillJsonWithState(_statePost); - m_TestObject["postStateRoot"] = jsonHex(_statePost.rootHash().asBytes()); + m_TestObject["postStateRoot"] = toString(_statePost.rootHash().asBytes()); // export pre state m_TestObject["pre"] = fillJsonWithState(m_statePre); @@ -352,29 +352,18 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) m_TestObject["transaction"] = makeAllFieldsHex(m_TestObject["transaction"].get_obj()); } -std::string jsonHash(h256 const& _value) { return toString(_value); } -std::string jsonHash(Nonce const& _value) { return toString(_value); } -std::string jsonHash(LogBloom const& _value) { return toString(_value); } -std::string jsonHash(Address const& _value) { return toString(_value); } -std::string jsonHex(bytesConstRef _code) { return "0x" + toHex(_code); } -std::string jsonHex(bytes const& _code) { return "0x" + toHex(_code); } -std::string jsonHex(u256 const& _value, bool _nonempty) -{ - return "0x" + toHex(toCompactBigEndian(_value, _nonempty ? 1 : 0)); -} - json_spirit::mObject fillJsonWithTransaction(Transaction _txn) { json_spirit::mObject txObject; - txObject["nonce"] = jsonHex(_txn.nonce()); - txObject["data"] = jsonHex(_txn.data()); - txObject["gasLimit"] = jsonHex(_txn.gas()); - txObject["gasPrice"] = jsonHex(_txn.gasPrice()); - txObject["r"] = jsonHex(_txn.signature().r); - txObject["s"] = jsonHex(_txn.signature().s); - txObject["v"] = jsonHex(_txn.signature().v + 27); - txObject["to"] = _txn.isCreation() ? "" : jsonHash(_txn.receiveAddress()); - txObject["value"] = jsonHex(_txn.value()); + txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add); + txObject["data"] = "0x"+toString(_txn.data()); + txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add); + txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add); + txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add); + txObject["s"] = toCompactHex(_txn.signature().s, HexPrefix::Add); + txObject["v"] = toCompactHex(_txn.signature().v + 27, HexPrefix::Add); + txObject["to"] = _txn.isCreation() ? "" : toString(_txn.receiveAddress()); + txObject["value"] = toCompactHex(_txn.value(), HexPrefix::Add); return txObject; } @@ -384,16 +373,15 @@ json_spirit::mObject fillJsonWithState(State _state) for (auto const& a: _state.addresses()) { json_spirit::mObject o; - o["balance"] = jsonHex(_state.balance(a.first)); - o["nonce"] = jsonHex(_state.transactionsFrom(a.first)); + o["balance"] = toCompactHex(_state.balance(a.first), HexPrefix::Add); + o["nonce"] = toCompactHex(_state.transactionsFrom(a.first), HexPrefix::Add); { json_spirit::mObject store; for (auto const& s: _state.storage(a.first)) - store[jsonHex(s.first)] = jsonHex(s.second); + store[toCompactHex(s.first, HexPrefix::Add)] = toCompactHex(s.second, HexPrefix::Add); o["storage"] = store; } - o["code"] = jsonHex(_state.code(a.first)); - + o["code"] = "0x" + toString(_state.code(a.first)); oState[toString(a.first)] = o; } return oState; @@ -406,13 +394,13 @@ json_spirit::mArray exportLog(eth::LogEntries _logs) for (LogEntry const& l: _logs) { json_spirit::mObject o; - o["address"] = jsonHash(l.address); + o["address"] = toString(l.address); json_spirit::mArray topics; for (auto const& t: l.topics) topics.push_back(toString(t)); o["topics"] = topics; - o["data"] = jsonHex(l.data); - o["bloom"] = jsonHash(l.bloom()); + o["data"] = "0x" + toString(l.data); + o["bloom"] = toString(l.bloom()); ret.push_back(o); } return ret; diff --git a/TestHelper.h b/TestHelper.h index 1e09cf69..10e76aa9 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -162,13 +162,6 @@ RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj); eth::LastHashes lastHashes(u256 _currentBlockNumber); json_spirit::mObject fillJsonWithState(eth::State _state); json_spirit::mObject fillJsonWithTransaction(eth::Transaction _txn); -std::string jsonHash(dev::eth::LogBloom const& _value); -std::string jsonHash(Address const& _value); -std::string jsonHash(dev::eth::Nonce const& _value); -std::string jsonHash(h256 const& _value); -std::string jsonHex(u256 const& _value, bool _nonempty = true); -std::string jsonHex(bytesConstRef _code); -std::string jsonHex(bytes const& _code); template void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs) -- cgit v1.2.3 From a5535ec86f9cd0f5db4b961936a1c3af7cf042b4 Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 23 Apr 2015 03:42:45 +0300 Subject: BlockWeight: data fix refactoring --- TestHelper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 0aa508c2..69ad7dba 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -327,7 +327,7 @@ void ImportTest::checkExpectedState(State const& _stateExpect, State const& _sta void ImportTest::exportTest(bytes const& _output, State const& _statePost) { // export output - m_TestObject["out"] = "0x" + toString(_output); + m_TestObject["out"] = toHex(_output, 2, HexPrefix::Add); // export logs m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries()); @@ -356,7 +356,7 @@ json_spirit::mObject fillJsonWithTransaction(Transaction _txn) { json_spirit::mObject txObject; txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add); - txObject["data"] = "0x"+toString(_txn.data()); + txObject["data"] = toHex(_txn.data(), 2, HexPrefix::Add); txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add); txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add); txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add); @@ -381,7 +381,7 @@ json_spirit::mObject fillJsonWithState(State _state) store[toCompactHex(s.first, HexPrefix::Add)] = toCompactHex(s.second, HexPrefix::Add); o["storage"] = store; } - o["code"] = "0x" + toString(_state.code(a.first)); + o["code"] = toHex(_state.code(a.first), 2, HexPrefix::Add); oState[toString(a.first)] = o; } return oState; @@ -399,7 +399,7 @@ json_spirit::mArray exportLog(eth::LogEntries _logs) for (auto const& t: l.topics) topics.push_back(toString(t)); o["topics"] = topics; - o["data"] = "0x" + toString(l.data); + o["data"] = toHex(l.data, 2, HexPrefix::Add); o["bloom"] = toString(l.bloom()); ret.push_back(o); } -- cgit v1.2.3 -- cgit v1.2.3 From d872539b1fd74452137309ac94fbb89e4faf6f43 Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 23 Apr 2015 13:09:23 +0300 Subject: blockweight: stateroot is hash --- TestHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 69ad7dba..b8e320e4 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -344,7 +344,7 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) // export post state m_TestObject["post"] = fillJsonWithState(_statePost); - m_TestObject["postStateRoot"] = toString(_statePost.rootHash().asBytes()); + m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes()); // export pre state m_TestObject["pre"] = fillJsonWithState(m_statePre); -- cgit v1.2.3 From 1580c38d667b3bdf4a01c878aae20efceb58e27a Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 23 Apr 2015 17:57:59 +0300 Subject: blockweight: allfields to compact Hex fix --- TestHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index b8e320e4..57ec0566 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -137,7 +137,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o) str = value.get_str(); else continue; - _o[key] = (str.substr(0, 2) == "0x") ? str : toHex(toInt(str), HexPrefix::Add); + _o[key] = (str.substr(0, 2) == "0x") ? str : toCompactHex(toInt(str), HexPrefix::Add); } return _o; } -- cgit v1.2.3 From 572d268f2860773562ce83719432c05af47c7528 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Sun, 26 Apr 2015 17:40:35 +0200 Subject: Squashed 'libjsqrc/ethereumjs/' changes from c74c854..3b799d1 3b799d1 fixed typos c5f6379 version 0.3.3 d795d36 fixed trimming call output prefix a2f561f fixed calling contract only with array param 4912ec6 tests for decoding solidity params 2b4fd21 solidity param encoding tests git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 3b799d128452639463424c657956ee90a28daec6 --- coder.decodeParam.js | 69 +++++++++++++++++++++++++++------ coder.encodeParam.js | 92 ++++++++++++++++++++++++++++++++++++++------ contract.js | 49 +++++++++++++++++++++++ helpers/FakeHttpProvider.js | 8 +++- helpers/FakeHttpProvider2.js | 27 +++++++++++++ 5 files changed, 219 insertions(+), 26 deletions(-) create mode 100644 helpers/FakeHttpProvider2.js diff --git a/coder.decodeParam.js b/coder.decodeParam.js index 0a67bda0..3eea9dd6 100644 --- a/coder.decodeParam.js +++ b/coder.decodeParam.js @@ -1,23 +1,68 @@ var chai = require('chai'); var assert = chai.assert; var coder = require('../lib/solidity/coder'); +var BigNumber = require('bignumber.js'); +var bn = BigNumber; -var tests = [ - { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000001', expected: 1}, - { type: 'int', value: '0000000000000000000000000000000000000000000000000000000000000010', expected: 16}, - { type: 'int', value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: -1}, - { type: 'bytes32', value: '6761766f66796f726b0000000000000000000000000000000000000000000000', expected: 'gavofyork'}, - { type: 'bytes', value: '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000', expected: 'gavofyork'} -]; describe('lib/solidity/coder', function () { describe('decodeParam', function () { - tests.forEach(function (test) { - it('should turn ' + test.value + ' to ' + test.expected, function () { - assert.equal(coder.decodeParam(test.type, test.value), test.expected); + var test = function (t) { + it('should turn ' + t.value + ' to ' + t.expected, function () { + assert.deepEqual(coder.decodeParam(t.type, t.value), t.expected); }); - }); + }; + + + test({ type: 'int', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ type: 'int', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); + test({ type: 'int256', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ type: 'int256', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int256', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); + test({ type: 'bytes32', expected: 'gavofyork', value: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'int[]', expected: [new bn(3)], value: '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ type: 'int256[]', expected: [new bn(3)], value: '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ type: 'int[]', expected: [new bn(1), new bn(2), new bn(3)], + value: '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000002' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + }); +}); + +describe('lib/solidity/coder', function () { + describe('decodeParams', function () { + var test = function (t) { + it('should turn ' + t.values + ' to ' + t.expected, function () { + assert.deepEqual(coder.decodeParams(t.types, t.values), t.expected); + }); + }; + + + test({ types: ['int'], expected: [new bn(1)], values: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ types: ['bytes32', 'int'], expected: ['gavofyork', new bn(5)], + values: '6761766f66796f726b0000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000005'}); + test({ types: ['int', 'bytes32'], expected: [new bn(5), 'gavofyork'], + values: '0000000000000000000000000000000000000000000000000000000000000005' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['int', 'bytes', 'int', 'int', 'int', 'int[]'], expected: [new bn(1), 'gavofyork', new bn(2), new bn(3), new bn(4), + [new bn(5), new bn(6), new bn(7)]], + values: '0000000000000000000000000000000000000000000000000000000000000009' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000002' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000004' + + '6761766f66796f726b0000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000005' + + '0000000000000000000000000000000000000000000000000000000000000006' + + '0000000000000000000000000000000000000000000000000000000000000007'}); }); }); diff --git a/coder.encodeParam.js b/coder.encodeParam.js index 1a4df06b..a9e11ab9 100644 --- a/coder.encodeParam.js +++ b/coder.encodeParam.js @@ -2,22 +2,90 @@ var chai = require('chai'); var assert = chai.assert; var coder = require('../lib/solidity/coder'); -var tests = [ - { type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}, - { type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}, - { type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, - { type: 'bytes32', value: 'gavofyork', expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}, - { type: 'bytes', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000009' + - '6761766f66796f726b0000000000000000000000000000000000000000000000'} -]; describe('lib/solidity/coder', function () { describe('encodeParam', function () { - tests.forEach(function (test) { - it('should turn ' + test.value + ' to ' + test.expected, function () { - assert.equal(coder.encodeParam(test.type, test.value), test.expected); + var test = function (t) { + it('should turn ' + t.value + ' to ' + t.expected, function () { + assert.equal(coder.encodeParam(t.type, t.value), t.expected); }); - }); + }; + + + test({ type: 'int', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ type: 'int', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); + test({ type: 'int256', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ type: 'int256', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ type: 'int256', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); + test({ type: 'bytes32', value: 'gavofyork', expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'bytes', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ type: 'int[]', value: [3], expected: '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ type: 'int256[]', value: [3], expected: '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ type: 'int[]', value: [1,2,3], expected: '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000002' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + }); +}); + + +describe('lib/solidity/coder', function () { + describe('encodeParams', function () { + var test = function (t) { + it('should turn ' + t.values + ' to ' + t.expected, function () { + assert.equal(coder.encodeParams(t.types, t.values), t.expected); + }); + }; + + + test({ types: ['int'], values: [1], expected: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ types: ['int'], values: [16], expected: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ types: ['int'], values: [-1], expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); + test({ types: ['int256'], values: [1], expected: '0000000000000000000000000000000000000000000000000000000000000001'}); + test({ types: ['int256'], values: [16], expected: '0000000000000000000000000000000000000000000000000000000000000010'}); + test({ types: ['int256'], values: [-1], expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}); + test({ types: ['bytes32'], values: ['gavofyork'], expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['bytes'], values: ['gavofyork'], expected: '0000000000000000000000000000000000000000000000000000000000000009' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['int[]'], values: [[3]], expected: '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ types: ['int256[]'], values: [[3]], expected: '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ types: ['int256[]'], values: [[1,2,3]], expected: '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000002' + + '0000000000000000000000000000000000000000000000000000000000000003'}); + test({ types: ['bytes32', 'int'], values: ['gavofyork', 5], + expected: '6761766f66796f726b0000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000005'}); + test({ types: ['int', 'bytes32'], values: [5, 'gavofyork'], + expected: '0000000000000000000000000000000000000000000000000000000000000005' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['bytes', 'int'], values: ['gavofyork', 5], + expected: '0000000000000000000000000000000000000000000000000000000000000009' + + '0000000000000000000000000000000000000000000000000000000000000005' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['int', 'bytes'], values: [5, 'gavofyork'], + expected: '0000000000000000000000000000000000000000000000000000000000000009' + + '0000000000000000000000000000000000000000000000000000000000000005' + + '6761766f66796f726b0000000000000000000000000000000000000000000000'}); + test({ types: ['int', 'bytes', 'int', 'int', 'int', 'int[]'], values: [1, 'gavofyork', 2, 3, 4, [5, 6, 7]], + expected: '0000000000000000000000000000000000000000000000000000000000000009' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000002' + + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000004' + + '6761766f66796f726b0000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000005' + + '0000000000000000000000000000000000000000000000000000000000000006' + + '0000000000000000000000000000000000000000000000000000000000000007'}); + }); }); + diff --git a/contract.js b/contract.js index db9840c5..8a2ea109 100644 --- a/contract.js +++ b/contract.js @@ -2,7 +2,9 @@ var chai = require('chai'); var assert = chai.assert; var web3 = require('../index'); var FakeHttpProvider = require('./helpers/FakeHttpProvider'); +var FakeHttpProvider2 = require('./helpers/FakeHttpProvider2'); var utils = require('../lib/utils/utils'); +var BigNumber = require('bignumber.js'); var desc = [{ "name": "balance(address)", @@ -27,6 +29,18 @@ var desc = [{ "type": "uint256" }], "outputs": [] +}, { + "name": "testArr(int[])", + "type": "function", + "inputs": [{ + "name": "value", + "type": "int[]" + }], + "constant": true, + "outputs": [{ + "name": "d", + "type": "int" + }] }, { "name":"Changed", "type":"event", @@ -313,5 +327,40 @@ describe('web3.eth.contract', function () { contract.send.sendTransaction(address, 17, {from: address, gas: 50000, gasPrice: 3000, value: 10000}); }); + + it('should call testArr method and properly parse result', function () { + var provider = new FakeHttpProvider2(); + web3.setProvider(provider); + web3.reset(); + var sha3 = '0x5131231231231231231231'; + var address = '0x1234567890123456789012345678901234567890'; + provider.injectResultList([{ + result: sha3 + }, { + result: '0x0000000000000000000000000000000000000000000000000000000000000005' + }]); + var step = 0; + provider.injectValidation(function (payload) { + if (step === 1) { // getting sha3 is first + assert.equal(payload.method, 'eth_call'); + assert.deepEqual(payload.params, [{ + data: sha3.slice(0, 10) + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000003', + to: address + }, + 'latest' + ]); + } + step++; + }); + + var Contract = web3.eth.contract(desc); + var contract = new Contract(address); + + var result = contract.testArr([3]); + + assert.deepEqual(new BigNumber(5), result); + }); }); }); diff --git a/helpers/FakeHttpProvider.js b/helpers/FakeHttpProvider.js index 20d1f258..0b01a171 100644 --- a/helpers/FakeHttpProvider.js +++ b/helpers/FakeHttpProvider.js @@ -26,7 +26,7 @@ FakeHttpProvider.prototype.send = function (payload) { // imitate plain json object this.validation(JSON.parse(JSON.stringify(payload))); } - return this.response; + return this.getResponse(); }; FakeHttpProvider.prototype.sendAsync = function (payload, callback) { @@ -36,7 +36,7 @@ FakeHttpProvider.prototype.sendAsync = function (payload, callback) { // imitate plain json object this.validation(JSON.parse(JSON.stringify(payload)), callback); } - callback(this.error, this.response); + callback(this.error, this.getResponse()); }; FakeHttpProvider.prototype.injectResponse = function (response) { @@ -56,6 +56,10 @@ FakeHttpProvider.prototype.injectBatchResults = function (results) { }); }; +FakeHttpProvider.prototype.getResponse = function () { + return this.response; +}; + FakeHttpProvider.prototype.injectError = function (error) { this.error = error; }; diff --git a/helpers/FakeHttpProvider2.js b/helpers/FakeHttpProvider2.js new file mode 100644 index 00000000..0f26d84b --- /dev/null +++ b/helpers/FakeHttpProvider2.js @@ -0,0 +1,27 @@ +var FakeHttpProvider = require('./FakeHttpProvider'); + +var FakeHttpProvider2 = function () { + this.counter = 0; + this.resultList = []; +}; + +FakeHttpProvider2.prototype = new FakeHttpProvider(); +FakeHttpProvider2.prototype.constructor = FakeHttpProvider2; + +FakeHttpProvider2.prototype.injectResultList = function (list) { + this.resultList = list; +}; + +FakeHttpProvider2.prototype.getResponse = function () { + var result = this.resultList[this.counter]; + this.counter++; + if (result.type === 'batch') { + this.injectBatchResults(result.result); + } else { + this.injectResult(result.result); + } + return this.response; +}; + +module.exports = FakeHttpProvider2; + -- cgit v1.2.3 From cfe24c3c2a60d59c0075e82fed044232baec4974 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 24 Apr 2015 11:42:30 +0200 Subject: Try to keep source location during optimization. --- libsolidity/SolidityOptimizer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp index af9b5146..ceb9c68d 100644 --- a/libsolidity/SolidityOptimizer.cpp +++ b/libsolidity/SolidityOptimizer.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -84,9 +85,20 @@ public: AssemblyItems getCSE(AssemblyItems const& _input) { + // add dummy locations to each item so that we can check that they are not deleted + AssemblyItems input = _input; + for (AssemblyItem& item: input) + item.setLocation(SourceLocation(1, 3, make_shared(""))); + eth::CommonSubexpressionEliminator cse; - BOOST_REQUIRE(cse.feedItems(_input.begin(), _input.end()) == _input.end()); - return cse.getOptimizedItems(); + BOOST_REQUIRE(cse.feedItems(input.begin(), input.end()) == input.end()); + AssemblyItems output = cse.getOptimizedItems(); + + for (AssemblyItem const& item: output) + { + BOOST_CHECK(item == Instruction::POP || !item.getLocation().isEmpty()); + } + return output; } void checkCSE(AssemblyItems const& _input, AssemblyItems const& _expectation) -- cgit v1.2.3 From 18475f8ae148ee797fbd649eb5bf7a870ed9957c Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 16 Apr 2015 15:19:25 +0200 Subject: test for resalts --- libsolidity/SolidityABIJSON.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libsolidity/SolidityABIJSON.cpp b/libsolidity/SolidityABIJSON.cpp index f0e54a94..1ba0dc7b 100644 --- a/libsolidity/SolidityABIJSON.cpp +++ b/libsolidity/SolidityABIJSON.cpp @@ -495,6 +495,27 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(constructor_abi) +{ + char const* sourceCode = R"( + contract test { + function test() { + } + })"; + + char const* interface = R"(" + [ + { + "constant" : false, + "inputs" : [], + "name" : "test", + "outputs" : [], + "type" : "constructor" + } + ])"; + checkInterface(sourceCode, interface); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3 From 9b956e809df8b84ce9ecfe866fe14473f4bbeece Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 17 Apr 2015 15:26:12 +0200 Subject: fixed the output of the test --- libsolidity/SolidityABIJSON.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libsolidity/SolidityABIJSON.cpp b/libsolidity/SolidityABIJSON.cpp index 1ba0dc7b..de2af1d2 100644 --- a/libsolidity/SolidityABIJSON.cpp +++ b/libsolidity/SolidityABIJSON.cpp @@ -499,19 +499,18 @@ BOOST_AUTO_TEST_CASE(constructor_abi) { char const* sourceCode = R"( contract test { - function test() { + function test() { } })"; - char const* interface = R"(" - [ - { - "constant" : false, - "inputs" : [], - "name" : "test", - "outputs" : [], - "type" : "constructor" - } + char const* interface = R"([ + { + "constant" : false, + "inputs" : [], + "name" : "test", + "outputs" : [], + "type" : "constructor" + } ])"; checkInterface(sourceCode, interface); } -- cgit v1.2.3 From 5b07f1133029e04c6db8510d80634d606e9d0e8e Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 22 Apr 2015 17:00:22 +0200 Subject: changed the implementation --- libsolidity/SolidityABIJSON.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libsolidity/SolidityABIJSON.cpp b/libsolidity/SolidityABIJSON.cpp index de2af1d2..f9ecb7d9 100644 --- a/libsolidity/SolidityABIJSON.cpp +++ b/libsolidity/SolidityABIJSON.cpp @@ -505,11 +505,8 @@ BOOST_AUTO_TEST_CASE(constructor_abi) char const* interface = R"([ { - "constant" : false, - "inputs" : [], - "name" : "test", - "outputs" : [], - "type" : "constructor" + "inputs" : [], + "type" : "constructor" } ])"; checkInterface(sourceCode, interface); -- cgit v1.2.3 From 21ced7e9c5123255dae9da0ba7a09e7545df6383 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 22 Apr 2015 18:53:58 +0200 Subject: changed the test so constructor will have input parameters --- libsolidity/SolidityABIJSON.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libsolidity/SolidityABIJSON.cpp b/libsolidity/SolidityABIJSON.cpp index f9ecb7d9..26d0110b 100644 --- a/libsolidity/SolidityABIJSON.cpp +++ b/libsolidity/SolidityABIJSON.cpp @@ -499,14 +499,27 @@ BOOST_AUTO_TEST_CASE(constructor_abi) { char const* sourceCode = R"( contract test { - function test() { + function test(uint param1, test param2, bool param3) {} } - })"; + )"; char const* interface = R"([ { - "inputs" : [], - "type" : "constructor" + "inputs": [ + { + "name": "param1", + "type": "uint256" + }, + { + "name": "param2", + "type": "address" + }, + { + "name": "param3", + "type": "bool" + } + ], + "type": "constructor" } ])"; checkInterface(sourceCode, interface); -- cgit v1.2.3 From 7ad5cb9621492f4ef8bfe4d8f6cf0a0aeedc6567 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 27 Apr 2015 18:31:38 +0200 Subject: Removed visit functions for abstract AST nodes. --- libsolidity/SolidityExpressionCompiler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libsolidity/SolidityExpressionCompiler.cpp b/libsolidity/SolidityExpressionCompiler.cpp index b2436cfa..ee631197 100644 --- a/libsolidity/SolidityExpressionCompiler.cpp +++ b/libsolidity/SolidityExpressionCompiler.cpp @@ -50,14 +50,12 @@ public: FirstExpressionExtractor(ASTNode& _node): m_expression(nullptr) { _node.accept(*this); } Expression* getExpression() const { return m_expression; } private: - virtual bool visit(Expression& _expression) override { return checkExpression(_expression); } virtual bool visit(Assignment& _expression) override { return checkExpression(_expression); } virtual bool visit(UnaryOperation& _expression) override { return checkExpression(_expression); } virtual bool visit(BinaryOperation& _expression) override { return checkExpression(_expression); } virtual bool visit(FunctionCall& _expression) override { return checkExpression(_expression); } virtual bool visit(MemberAccess& _expression) override { return checkExpression(_expression); } virtual bool visit(IndexAccess& _expression) override { return checkExpression(_expression); } - virtual bool visit(PrimaryExpression& _expression) override { return checkExpression(_expression); } virtual bool visit(Identifier& _expression) override { return checkExpression(_expression); } virtual bool visit(ElementaryTypeNameExpression& _expression) override { return checkExpression(_expression); } virtual bool visit(Literal& _expression) override { return checkExpression(_expression); } -- cgit v1.2.3 From f843161bd97eabec7a3939bc6998337dfd22e319 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 27 Apr 2015 19:22:53 +0200 Subject: Full ICAP implementation (Direct, Indirect-ETH, Indirect-XET). --- webthreestubclient.h | 626 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 626 insertions(+) create mode 100644 webthreestubclient.h diff --git a/webthreestubclient.h b/webthreestubclient.h new file mode 100644 index 00000000..51d556ee --- /dev/null +++ b/webthreestubclient.h @@ -0,0 +1,626 @@ +/** + * This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! + */ + +#ifndef JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ +#define JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ + +#include + +class WebThreeStubClient : public jsonrpc::Client +{ + public: + WebThreeStubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} + + std::string web3_sha3(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("web3_sha3",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string web3_clientVersion() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("web3_clientVersion",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string net_version() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_version",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string net_peerCount() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_peerCount",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool net_listening() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_listening",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_protocolVersion() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_protocolVersion",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_hashrate() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_hashrate",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_coinbase() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_coinbase",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_mining() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_mining",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_gasPrice() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_gasPrice",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_accounts() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_accounts",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_blockNumber() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_blockNumber",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getBalance(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getBalance",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getStorageAt(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + p.append(param3); + Json::Value result = this->CallMethod("eth_getStorageAt",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getTransactionCount(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getTransactionCount",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getBlockTransactionCountByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getBlockTransactionCountByHash",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getBlockTransactionCountByNumber(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getBlockTransactionCountByNumber",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getUncleCountByBlockHash(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getUncleCountByBlockHash",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getUncleCountByBlockNumber(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getUncleCountByBlockNumber",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_getCode(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getCode",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_sendTransaction(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_sendTransaction",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_call(const Json::Value& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_call",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_flush() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_flush",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getBlockByHash(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getBlockByHash",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getBlockByNumber(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getBlockByNumber",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getTransactionByHash(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getTransactionByHash",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getTransactionByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getTransactionByBlockHashAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getTransactionByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getTransactionByBlockNumberAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getUncleByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getUncleByBlockHashAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getUncleByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("eth_getUncleByBlockNumberAndIndex",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getCompilers() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_getCompilers",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_compileLLL(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_compileLLL",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_compileSerpent(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_compileSerpent",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_compileSolidity(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_compileSolidity",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_newFilter",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_newBlockFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_newBlockFilter",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_uninstallFilter",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getFilterChanges",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getFilterLogs(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getFilterLogs",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getLogs(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_getLogs",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_getWork() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("eth_getWork",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_submitWork(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + p.append(param3); + Json::Value result = this->CallMethod("eth_submitWork",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_register(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_register",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_unregister(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_unregister",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_fetchQueuedTransactions(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_fetchQueuedTransactions",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string eth_signTransaction(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_signTransaction",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value eth_inspectTransaction(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_inspectTransaction",p); + if (result.isObject()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool eth_injectTransaction(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("eth_injectTransaction",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool db_put(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + p.append(param3); + Json::Value result = this->CallMethod("db_put",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string db_get(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("db_get",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool shh_post(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_post",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_newIdentity() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("shh_newIdentity",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool shh_hasIdentity(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_hasIdentity",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_newGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("shh_newGroup",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_addToGroup(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("shh_addToGroup",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_newFilter",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + bool shh_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_uninstallFilter",p); + if (result.isBool()) + return result.asBool(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value shh_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_getFilterChanges",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + Json::Value shh_getMessages(const std::string& param1) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + Json::Value result = this->CallMethod("shh_getMessages",p); + if (result.isArray()) + return result; + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } +}; + +#endif //JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_ -- cgit v1.2.3 From 50644d2e1054c39f4abf5decf8a3cd8ad196fb06 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 27 Apr 2015 23:30:28 +0200 Subject: Tidy and conformalise the toHex API. --- TestHelper.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 57ec0566..eecf6f80 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -137,7 +137,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o) str = value.get_str(); else continue; - _o[key] = (str.substr(0, 2) == "0x") ? str : toCompactHex(toInt(str), HexPrefix::Add); + _o[key] = (str.substr(0, 2) == "0x") ? str : toCompactHex(toInt(str), HexPrefix::Add, 1); } return _o; } @@ -355,15 +355,15 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) json_spirit::mObject fillJsonWithTransaction(Transaction _txn) { json_spirit::mObject txObject; - txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add); + txObject["nonce"] = toCompactHex(_txn.nonce(), HexPrefix::Add, 1); txObject["data"] = toHex(_txn.data(), 2, HexPrefix::Add); - txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add); - txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add); - txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add); - txObject["s"] = toCompactHex(_txn.signature().s, HexPrefix::Add); - txObject["v"] = toCompactHex(_txn.signature().v + 27, HexPrefix::Add); + txObject["gasLimit"] = toCompactHex(_txn.gas(), HexPrefix::Add, 1); + txObject["gasPrice"] = toCompactHex(_txn.gasPrice(), HexPrefix::Add, 1); + txObject["r"] = toCompactHex(_txn.signature().r, HexPrefix::Add, 1); + txObject["s"] = toCompactHex(_txn.signature().s, HexPrefix::Add, 1); + txObject["v"] = toCompactHex(_txn.signature().v + 27, HexPrefix::Add, 1); txObject["to"] = _txn.isCreation() ? "" : toString(_txn.receiveAddress()); - txObject["value"] = toCompactHex(_txn.value(), HexPrefix::Add); + txObject["value"] = toCompactHex(_txn.value(), HexPrefix::Add, 1); return txObject; } @@ -373,12 +373,12 @@ json_spirit::mObject fillJsonWithState(State _state) for (auto const& a: _state.addresses()) { json_spirit::mObject o; - o["balance"] = toCompactHex(_state.balance(a.first), HexPrefix::Add); - o["nonce"] = toCompactHex(_state.transactionsFrom(a.first), HexPrefix::Add); + o["balance"] = toCompactHex(_state.balance(a.first), HexPrefix::Add, 1); + o["nonce"] = toCompactHex(_state.transactionsFrom(a.first), HexPrefix::Add, 1); { json_spirit::mObject store; for (auto const& s: _state.storage(a.first)) - store[toCompactHex(s.first, HexPrefix::Add)] = toCompactHex(s.second, HexPrefix::Add); + store[toCompactHex(s.first, HexPrefix::Add, 1)] = toCompactHex(s.second, HexPrefix::Add, 1); o["storage"] = store; } o["code"] = toHex(_state.code(a.first), 2, HexPrefix::Add); -- cgit v1.2.3 From 0e5331f62c1a5384b9cff20c5499c89c12b82c5b Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 28 Apr 2015 11:31:40 +0200 Subject: Fix for deleting byte array elements. Fixes #1759. --- libsolidity/SolidityEndToEndTest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 596f710b..24e5f7b4 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -3381,6 +3381,26 @@ BOOST_AUTO_TEST_CASE(bytes_index_access) BOOST_CHECK(callContractFunction("storageWrite()") == encodeArgs(0x193)); } +BOOST_AUTO_TEST_CASE(bytes_delete_element) +{ + char const* sourceCode = R"( + contract c { + bytes data; + function test1() external returns (bool) { + data.length = 100; + for (uint i = 0; i < data.length; i++) + data[i] = byte(i); + delete data[94]; + delete data[96]; + delete data[98]; + return data[94] == 0 && data[95] == 95 && data[96] == 0 && data[97] == 97; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test1()") == encodeArgs(true)); +} + BOOST_AUTO_TEST_CASE(array_copy_calldata_storage) { char const* sourceCode = R"( -- cgit v1.2.3