diff --git a/api/api.go b/api/api.go index 77bfc68ae..6ceb6e9d4 100644 --- a/api/api.go +++ b/api/api.go @@ -2,6 +2,7 @@ package api import ( "context" + "encoding/hex" "fmt" "math/big" @@ -10,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/rpc" "github.com/onflow/flow-evm-gateway/storage" @@ -65,7 +67,7 @@ func (api *BlockChainAPI) SendRawTransaction( ctx context.Context, input hexutil.Bytes, ) (common.Hash, error) { - return common.Hash{}, nil + return crypto.Keccak256Hash([]byte("hello world")), nil } // eth_createAccessList @@ -105,7 +107,7 @@ func (s *BlockChainAPI) FeeHistory( // eth_gasPrice (returns the gas price) // GasPrice returns a suggestion for a gas price for legacy transactions. func (s *BlockChainAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { - return (*hexutil.Big)(big.NewInt(10102020506)), nil + return (*hexutil.Big)(big.NewInt(8049999872)), nil } // eth_maxPriorityFeePerGas @@ -133,7 +135,8 @@ func (s *BlockChainAPI) GetCode( address common.Address, blockNumberOrHash *rpc.BlockNumberOrHash, ) (hexutil.Bytes, error) { - return hexutil.Bytes{}, nil + code, _ := hex.DecodeString("600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056") + return hexutil.Bytes(code), nil } // eth_getProof (returns state proof for an account) @@ -166,7 +169,8 @@ func (s *BlockChainAPI) GetStorageAt( storageSlot string, blockNumberOrHash *rpc.BlockNumberOrHash, ) (hexutil.Bytes, error) { - return hexutil.Bytes{}, nil + storage, _ := hex.DecodeString("600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056") + return hexutil.Bytes(storage), nil } // eth_getTransactionCount (returns the number of tx sent from an address (nonce)) @@ -186,7 +190,27 @@ func (s *BlockChainAPI) GetTransactionByHash( ctx context.Context, hash common.Hash, ) (*RPCTransaction, error) { - return &RPCTransaction{}, nil + blockHash := common.HexToHash("0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2") + to := common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + index := uint64(64) + + tx := &RPCTransaction{ + BlockHash: (*common.Hash)(&blockHash), + BlockNumber: (*hexutil.Big)(big.NewInt(6139707)), + From: common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d"), + Gas: hexutil.Uint64(50000), + GasPrice: (*hexutil.Big)(big.NewInt(20000000000)), + Hash: common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"), + Input: hexutil.Bytes("0x68656c6c6f21"), + Nonce: hexutil.Uint64(21), + To: &to, + TransactionIndex: (*hexutil.Uint64)(&index), + Value: (*hexutil.Big)(big.NewInt(4290000000000000)), + V: (*hexutil.Big)(big.NewInt(37)), + R: (*hexutil.Big)(big.NewInt(150)), + S: (*hexutil.Big)(big.NewInt(250)), + } + return tx, nil } // eth_getTransactionByBlockHashAndIndex @@ -196,7 +220,26 @@ func (s *BlockChainAPI) GetTransactionByBlockHashAndIndex( blockHash common.Hash, index hexutil.Uint, ) *RPCTransaction { - return &RPCTransaction{} + to := common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + txIndex := uint64(64) + + tx := &RPCTransaction{ + BlockHash: (*common.Hash)(&blockHash), + BlockNumber: (*hexutil.Big)(big.NewInt(6139707)), + From: common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d"), + Gas: hexutil.Uint64(50000), + GasPrice: (*hexutil.Big)(big.NewInt(20000000000)), + Hash: common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"), + Input: hexutil.Bytes("0x68656c6c6f21"), + Nonce: hexutil.Uint64(21), + To: &to, + TransactionIndex: (*hexutil.Uint64)(&txIndex), + Value: (*hexutil.Big)(big.NewInt(4290000000000000)), + V: (*hexutil.Big)(big.NewInt(37)), + R: (*hexutil.Big)(big.NewInt(150)), + S: (*hexutil.Big)(big.NewInt(250)), + } + return tx } // eth_getTransactionByBlockNumberAndIndex @@ -206,7 +249,27 @@ func (s *BlockChainAPI) GetTransactionByBlockNumberAndIndex( blockNumber rpc.BlockNumber, index hexutil.Uint, ) *RPCTransaction { - return &RPCTransaction{} + blockHash := common.HexToHash("0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2") + to := common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + txIndex := uint64(64) + + tx := &RPCTransaction{ + BlockHash: (*common.Hash)(&blockHash), + BlockNumber: (*hexutil.Big)(big.NewInt(6139707)), + From: common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d"), + Gas: hexutil.Uint64(50000), + GasPrice: (*hexutil.Big)(big.NewInt(20000000000)), + Hash: common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"), + Input: hexutil.Bytes("0x68656c6c6f21"), + Nonce: hexutil.Uint64(21), + To: &to, + TransactionIndex: (*hexutil.Uint64)(&txIndex), + Value: (*hexutil.Big)(big.NewInt(4290000000000000)), + V: (*hexutil.Big)(big.NewInt(37)), + R: (*hexutil.Big)(big.NewInt(150)), + S: (*hexutil.Big)(big.NewInt(250)), + } + return tx } // eth_getTransactionReceipt @@ -215,13 +278,30 @@ func (s *BlockChainAPI) GetTransactionReceipt( ctx context.Context, hash common.Hash, ) (map[string]interface{}, error) { - return map[string]interface{}{}, nil + receipt := map[string]interface{}{} + txIndex := uint64(64) + blockHash := common.HexToHash("0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2") + receipt["blockHash"] = blockHash + receipt["blockNumber"] = (*hexutil.Big)(big.NewInt(6139707)) + receipt["contractAddress"] = nil + receipt["cumulativeGasUsed"] = hexutil.Uint64(50000) + receipt["effectiveGasPrice"] = (*hexutil.Big)(big.NewInt(20000000000)) + receipt["from"] = common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d") + receipt["gasUsed"] = hexutil.Uint64(40000) + receipt["logs"] = []*types.Log{} + receipt["logsBloom"] = "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b" + receipt["status"] = hexutil.Uint64(1) + receipt["to"] = common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + receipt["transactionHash"] = common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b") + receipt["transactionIndex"] = (*hexutil.Uint64)(&txIndex) + receipt["type"] = hexutil.Uint64(2) + return receipt, nil } // eth_coinbase (return the coinbase for a block) // Coinbase is the address that mining rewards will be sent to (alias for Etherbase). func (s *BlockChainAPI) Coinbase() (common.Address, error) { - return common.Address{1, 2, 3, 4, 5}, nil + return common.HexToAddress("0x9b1d35635cc34752ca54713bb99d38614f63c955"), nil } // eth_getBlockByHash @@ -232,7 +312,28 @@ func (s *BlockChainAPI) GetBlockByHash( hash common.Hash, fullTx bool, ) (map[string]interface{}, error) { - return map[string]interface{}{}, nil + block := map[string]interface{}{} + block["difficulty"] = "0x4ea3f27bc" + block["extraData"] = "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32" + block["gasLimit"] = "0x1388" + block["gasUsed"] = "0x0" + block["hash"] = "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae" + block["logsBloom"] = "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + block["miner"] = "0xbb7b8287f3f0a933474a79eae42cbca977791171" + block["mixHash"] = "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843" + block["nonce"] = "0x689056015818adbe" + block["number"] = "0x1b4" + block["parentHash"] = "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54" + block["receiptsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + block["sha3Uncles"] = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + block["size"] = "0x220" + block["stateRoot"] = "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d" + block["timestamp"] = "0x55ba467c" + block["totalDifficulty"] = "0x78ed983323d" + block["transactions"] = []string{} + block["transactionsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + block["uncles"] = []string{} + return block, nil } // eth_getBlockByNumber @@ -248,7 +349,28 @@ func (s *BlockChainAPI) GetBlockByNumber( blockNumber rpc.BlockNumber, fullTx bool, ) (map[string]interface{}, error) { - return map[string]interface{}{}, nil + block := map[string]interface{}{} + block["difficulty"] = "0x4ea3f27bc" + block["extraData"] = "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32" + block["gasLimit"] = "0x1388" + block["gasUsed"] = "0x0" + block["hash"] = "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae" + block["logsBloom"] = "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + block["miner"] = "0xbb7b8287f3f0a933474a79eae42cbca977791171" + block["mixHash"] = "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843" + block["nonce"] = "0x689056015818adbe" + block["number"] = "0x1b4" + block["parentHash"] = "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54" + block["receiptsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + block["sha3Uncles"] = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + block["size"] = "0x220" + block["stateRoot"] = "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d" + block["timestamp"] = "0x55ba467c" + block["totalDifficulty"] = "0x78ed983323d" + block["transactions"] = []string{} + block["transactionsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + block["uncles"] = []string{} + return block, nil } // eth_getBlockReceipts @@ -310,8 +432,18 @@ func (s *BlockChainAPI) GetLogs( if len(criteria.Topics) > maxTopics { return nil, errExceedMaxTopics } + log := &types.Log{ + Index: 1, + BlockNumber: 436, + BlockHash: common.HexToHash("0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + TxHash: common.HexToHash("0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"), + TxIndex: 0, + Address: common.HexToAddress("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + Data: []byte{0, 0, 0}, + Topics: []common.Hash{common.HexToHash("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")}, + } - return []*types.Log{}, nil + return []*types.Log{log}, nil } // eth_newFilter @@ -345,7 +477,18 @@ func (s *BlockChainAPI) GetFilterLogs( ctx context.Context, id rpc.ID, ) ([]*types.Log, error) { - return []*types.Log{}, nil + log := &types.Log{ + Index: 1, + BlockNumber: 436, + BlockHash: common.HexToHash("0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + TxHash: common.HexToHash("0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"), + TxIndex: 0, + Address: common.HexToAddress("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + Data: []byte{0, 0, 0}, + Topics: []common.Hash{common.HexToHash("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")}, + } + + return []*types.Log{log}, nil } // eth_getFilterChanges @@ -358,7 +501,18 @@ func (s *BlockChainAPI) GetFilterChanges(id rpc.ID) (interface{}, error) { if id == rpc.ID("") { return nil, errFilterNotFound } - return []interface{}{}, nil + log := &types.Log{ + Index: 1, + BlockNumber: 436, + BlockHash: common.HexToHash("0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + TxHash: common.HexToHash("0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"), + TxIndex: 0, + Address: common.HexToAddress("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + Data: []byte{0, 0, 0}, + Topics: []common.Hash{common.HexToHash("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")}, + } + + return []*types.Log{log}, nil } // eth_newBlockFilter @@ -381,7 +535,9 @@ func (s *BlockChainAPI) NewPendingTransactionFilter(fullTx *bool) rpc.ID { // eth_accounts // Accounts returns the collection of accounts this node manages. func (s *BlockChainAPI) Accounts() []common.Address { - return []common.Address{} + return []common.Address{ + common.HexToAddress("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), + } } // eth_sign @@ -440,7 +596,7 @@ func (s *BlockChainAPI) Call( overrides *StateOverride, blockOverrides *BlockOverrides, ) (hexutil.Bytes, error) { - return hexutil.Bytes{}, nil + return hexutil.Bytes{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, nil } // eth_estimateGas (usually runs the call and checks how much gas might be used) diff --git a/api/api_test.go b/api/api_test.go index e7ba928bc..a6acd3806 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -3,6 +3,7 @@ package api_test import ( "context" "crypto/ecdsa" + "encoding/hex" "math/big" "testing" @@ -61,7 +62,11 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, common.Hash{}, hash) + assert.Equal( + t, + common.HexToHash("0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"), + hash, + ) }) t.Run("CreateAccessList", func(t *testing.T) { @@ -102,7 +107,7 @@ func TestBlockChainAPI(t *testing.T) { gasPrice, err := blockchainAPI.GasPrice(context.Background()) require.NoError(t, err) - assert.Equal(t, gasPrice, (*hexutil.Big)(big.NewInt(10102020506))) + assert.Equal(t, gasPrice, (*hexutil.Big)(big.NewInt(8049999872))) }) t.Run("MaxPriorityFeePerGas", func(t *testing.T) { @@ -151,7 +156,8 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, hexutil.Bytes{}, storage) + expected, _ := hex.DecodeString("600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056") + assert.Equal(t, hexutil.Bytes(expected), storage) }) t.Run("GetTransactionCount", func(t *testing.T) { @@ -176,17 +182,59 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, &api.RPCTransaction{}, tx) + blockHash := common.HexToHash("0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2") + to := common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + index := uint64(64) + + expectedTx := &api.RPCTransaction{ + BlockHash: (*common.Hash)(&blockHash), + BlockNumber: (*hexutil.Big)(big.NewInt(6139707)), + From: common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d"), + Gas: hexutil.Uint64(50000), + GasPrice: (*hexutil.Big)(big.NewInt(20000000000)), + Hash: common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"), + Input: hexutil.Bytes("0x68656c6c6f21"), + Nonce: hexutil.Uint64(21), + To: &to, + TransactionIndex: (*hexutil.Uint64)(&index), + Value: (*hexutil.Big)(big.NewInt(4290000000000000)), + V: (*hexutil.Big)(big.NewInt(37)), + R: (*hexutil.Big)(big.NewInt(150)), + S: (*hexutil.Big)(big.NewInt(250)), + } + + assert.Equal(t, expectedTx, tx) }) t.Run("GetTransactionByBlockHashAndIndex", func(t *testing.T) { + blockHash := common.Hash{0, 1, 2} tx := blockchainAPI.GetTransactionByBlockHashAndIndex( context.Background(), - common.Hash{0, 1, 2}, + blockHash, hexutil.Uint(105), ) - assert.Equal(t, &api.RPCTransaction{}, tx) + to := common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + txIndex := uint64(64) + + expectedTx := &api.RPCTransaction{ + BlockHash: (*common.Hash)(&blockHash), + BlockNumber: (*hexutil.Big)(big.NewInt(6139707)), + From: common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d"), + Gas: hexutil.Uint64(50000), + GasPrice: (*hexutil.Big)(big.NewInt(20000000000)), + Hash: common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"), + Input: hexutil.Bytes("0x68656c6c6f21"), + Nonce: hexutil.Uint64(21), + To: &to, + TransactionIndex: (*hexutil.Uint64)(&txIndex), + Value: (*hexutil.Big)(big.NewInt(4290000000000000)), + V: (*hexutil.Big)(big.NewInt(37)), + R: (*hexutil.Big)(big.NewInt(150)), + S: (*hexutil.Big)(big.NewInt(250)), + } + + assert.Equal(t, expectedTx, tx) }) t.Run("GetTransactionByBlockNumberAndIndex", func(t *testing.T) { @@ -196,7 +244,28 @@ func TestBlockChainAPI(t *testing.T) { hexutil.Uint(105), ) - assert.Equal(t, &api.RPCTransaction{}, tx) + blockHash := common.HexToHash("0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2") + to := common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + txIndex := uint64(64) + + expectedTx := &api.RPCTransaction{ + BlockHash: (*common.Hash)(&blockHash), + BlockNumber: (*hexutil.Big)(big.NewInt(6139707)), + From: common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d"), + Gas: hexutil.Uint64(50000), + GasPrice: (*hexutil.Big)(big.NewInt(20000000000)), + Hash: common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"), + Input: hexutil.Bytes("0x68656c6c6f21"), + Nonce: hexutil.Uint64(21), + To: &to, + TransactionIndex: (*hexutil.Uint64)(&txIndex), + Value: (*hexutil.Big)(big.NewInt(4290000000000000)), + V: (*hexutil.Big)(big.NewInt(37)), + R: (*hexutil.Big)(big.NewInt(150)), + S: (*hexutil.Big)(big.NewInt(250)), + } + + assert.Equal(t, expectedTx, tx) }) t.Run("GetTransactionReceipt", func(t *testing.T) { @@ -206,14 +275,36 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, map[string]interface{}{}, receipt) + expectedReceipt := map[string]interface{}{} + txIndex := uint64(64) + blockHash := common.HexToHash("0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2") + expectedReceipt["blockHash"] = blockHash + expectedReceipt["blockNumber"] = (*hexutil.Big)(big.NewInt(6139707)) + expectedReceipt["contractAddress"] = nil + expectedReceipt["cumulativeGasUsed"] = hexutil.Uint64(50000) + expectedReceipt["effectiveGasPrice"] = (*hexutil.Big)(big.NewInt(20000000000)) + expectedReceipt["from"] = common.HexToAddress("0xa7d9ddbe1f17865597fbd27ec712455208b6b76d") + expectedReceipt["gasUsed"] = hexutil.Uint64(40000) + expectedReceipt["logs"] = []*types.Log{} + expectedReceipt["logsBloom"] = "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b" + expectedReceipt["status"] = hexutil.Uint64(1) + expectedReceipt["to"] = common.HexToAddress("0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb") + expectedReceipt["transactionHash"] = common.HexToHash("0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b") + expectedReceipt["transactionIndex"] = (*hexutil.Uint64)(&txIndex) + expectedReceipt["type"] = hexutil.Uint64(2) + + assert.Equal(t, expectedReceipt, receipt) }) t.Run("Coinbase", func(t *testing.T) { addr, err := blockchainAPI.Coinbase() require.NoError(t, err) - assert.Equal(t, common.Address{1, 2, 3, 4, 5}, addr) + assert.Equal( + t, + common.HexToAddress("0x9B1d35635cC34752ca54713BB99d38614f63C955"), + addr, + ) }) t.Run("GetBlockByHash", func(t *testing.T) { @@ -224,7 +315,29 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, map[string]interface{}{}, block) + expectedBlock := map[string]interface{}{} + expectedBlock["difficulty"] = "0x4ea3f27bc" + expectedBlock["extraData"] = "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32" + expectedBlock["gasLimit"] = "0x1388" + expectedBlock["gasUsed"] = "0x0" + expectedBlock["hash"] = "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae" + expectedBlock["logsBloom"] = "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + expectedBlock["miner"] = "0xbb7b8287f3f0a933474a79eae42cbca977791171" + expectedBlock["mixHash"] = "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843" + expectedBlock["nonce"] = "0x689056015818adbe" + expectedBlock["number"] = "0x1b4" + expectedBlock["parentHash"] = "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54" + expectedBlock["receiptsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + expectedBlock["sha3Uncles"] = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + expectedBlock["size"] = "0x220" + expectedBlock["stateRoot"] = "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d" + expectedBlock["timestamp"] = "0x55ba467c" + expectedBlock["totalDifficulty"] = "0x78ed983323d" + expectedBlock["transactions"] = []string{} + expectedBlock["transactionsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + expectedBlock["uncles"] = []string{} + + assert.Equal(t, expectedBlock, block) }) t.Run("GetBlockByNumber", func(t *testing.T) { @@ -235,7 +348,29 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, map[string]interface{}{}, block) + expectedBlock := map[string]interface{}{} + expectedBlock["difficulty"] = "0x4ea3f27bc" + expectedBlock["extraData"] = "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32" + expectedBlock["gasLimit"] = "0x1388" + expectedBlock["gasUsed"] = "0x0" + expectedBlock["hash"] = "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae" + expectedBlock["logsBloom"] = "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + expectedBlock["miner"] = "0xbb7b8287f3f0a933474a79eae42cbca977791171" + expectedBlock["mixHash"] = "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843" + expectedBlock["nonce"] = "0x689056015818adbe" + expectedBlock["number"] = "0x1b4" + expectedBlock["parentHash"] = "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54" + expectedBlock["receiptsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + expectedBlock["sha3Uncles"] = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + expectedBlock["size"] = "0x220" + expectedBlock["stateRoot"] = "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d" + expectedBlock["timestamp"] = "0x55ba467c" + expectedBlock["totalDifficulty"] = "0x78ed983323d" + expectedBlock["transactions"] = []string{} + expectedBlock["transactionsRoot"] = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + expectedBlock["uncles"] = []string{} + + assert.Equal(t, expectedBlock, block) }) t.Run("GetBlockReceipts", func(t *testing.T) { @@ -295,7 +430,18 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, []*types.Log{}, logs) + log := &types.Log{ + Index: 1, + BlockNumber: 436, + BlockHash: common.HexToHash("0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + TxHash: common.HexToHash("0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"), + TxIndex: 0, + Address: common.HexToAddress("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + Data: []byte{0, 0, 0}, + Topics: []common.Hash{common.HexToHash("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")}, + } + + assert.Equal(t, []*types.Log{log}, logs) }) t.Run("NewFilter", func(t *testing.T) { @@ -320,7 +466,18 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, []*types.Log{}, logs) + log := &types.Log{ + Index: 1, + BlockNumber: 436, + BlockHash: common.HexToHash("0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + TxHash: common.HexToHash("0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"), + TxIndex: 0, + Address: common.HexToAddress("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + Data: []byte{0, 0, 0}, + Topics: []common.Hash{common.HexToHash("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")}, + } + + assert.Equal(t, []*types.Log{log}, logs) }) t.Run("GetFilterChanges", func(t *testing.T) { @@ -329,7 +486,18 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, []interface{}{}, changes) + log := &types.Log{ + Index: 1, + BlockNumber: 436, + BlockHash: common.HexToHash("0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + TxHash: common.HexToHash("0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"), + TxIndex: 0, + Address: common.HexToAddress("0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"), + Data: []byte{0, 0, 0}, + Topics: []common.Hash{common.HexToHash("0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")}, + } + + assert.Equal(t, []*types.Log{log}, changes) }) t.Run("NewBlockFilter", func(t *testing.T) { @@ -347,7 +515,13 @@ func TestBlockChainAPI(t *testing.T) { t.Run("Accounts", func(t *testing.T) { accounts := blockchainAPI.Accounts() - assert.Equal(t, []common.Address{}, accounts) + assert.Equal( + t, + []common.Address{ + common.HexToAddress("0x407D73d8a49eeb85D32Cf465507dd71d507100c1"), + }, + accounts, + ) }) t.Run("Sign", func(t *testing.T) { @@ -422,7 +596,7 @@ func TestBlockChainAPI(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, hexutil.Bytes{}, result) + assert.Equal(t, hexutil.Bytes{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, result) }) t.Run("EstimateGas", func(t *testing.T) { diff --git a/api/server_test.go b/api/server_test.go index 0f9e39ba1..32250334c 100644 --- a/api/server_test.go +++ b/api/server_test.go @@ -41,18 +41,68 @@ func TestRPCServer(t *testing.T) { url := "http://" + srv.ListenAddr() requests := []string{ - `{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params": []}`, - `{"jsonrpc":"2.0","id":2,"method":"eth_chainId","params": []}`, + `{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params": []}`, + `{"jsonrpc":"2.0","id":2,"method":"eth_blockNumber","params": []}`, `{"jsonrpc":"2.0","id":3,"method":"eth_syncing","params": []}`, - `{"jsonrpc":"2.0","id":4,"method":"eth_getBalance","params": ["0x407d73d8a49eeb85d32cf465507dd71d507100c1"]}`, - `{"jsonrpc":"2.0","id":5,"method":"eth_getBlockTransactionCountByNumber","params": ["0x4E4ee"]}`, + `{"jsonrpc":"2.0","id":4,"method":"eth_sendRawTransaction","params":["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"]}`, + `{"jsonrpc":"2.0","id":5,"method":"eth_gasPrice","params":[]}`, + `{"jsonrpc":"2.0","id":6,"method":"eth_getBalance","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1","latest"]}`, + `{"jsonrpc":"2.0","id":7,"method":"eth_getCode","params":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b","0x2"]}`, + `{"jsonrpc":"2.0","id":8,"method":"eth_getStorageAt","params":["0x295a70b2de5e3953354a6a8344e616ed314d7251","0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9","latest"]}`, + `{"jsonrpc":"2.0","id":9,"method":"eth_getTransactionCount","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1","latest"]}`, + `{"jsonrpc":"2.0","id":10,"method":"eth_getTransactionByHash","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"]}`, + `{"jsonrpc":"2.0","id":11,"method":"eth_getTransactionByBlockHashAndIndex","params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"]}`, + `{"jsonrpc":"2.0","id":12,"method":"eth_getTransactionByBlockNumberAndIndex","params":["0x29c", "0x0"]}`, + `{"jsonrpc":"2.0","id":13,"method":"eth_getTransactionReceipt","params":["0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5"]}`, + `{"jsonrpc":"2.0","id":14,"method":"eth_coinbase"}`, + `{"jsonrpc":"2.0","id":15,"method":"eth_getBlockByHash","params":["0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae",false]}`, + `{"jsonrpc":"2.0","id":16,"method":"eth_getBlockByNumber","params":["0x1b4",true]}`, + `{"jsonrpc":"2.0","id":17,"method":"eth_getBlockTransactionCountByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"]}`, + `{"jsonrpc":"2.0","id":18,"method":"eth_getBlockTransactionCountByNumber","params":["0xe8"]}`, + `{"jsonrpc":"2.0","id":19,"method":"eth_getUncleCountByBlockHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"]}`, + `{"jsonrpc":"2.0","id":20,"method":"eth_getUncleCountByBlockNumber","params":["0xe8"]}`, + `{"jsonrpc":"2.0","id":21,"method":"eth_getLogs","params":[{"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]}]}`, + `{"jsonrpc":"2.0","id":22,"method":"eth_newFilter","params":[{"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]}]}`, + `{"jsonrpc":"2.0","id":23,"method":"eth_uninstallFilter","params":["0xb"]}`, + `{"jsonrpc":"2.0","id":24,"method":"eth_getFilterLogs","params":["0x16"]}`, + `{"jsonrpc":"2.0","id":25,"method":"eth_getFilterChanges","params":["0x16"]}`, + `{"jsonrpc":"2.0","id":26,"method":"eth_newBlockFilter","params":[]}`, + `{"jsonrpc":"2.0","id":27,"method":"eth_newPendingTransactionFilter","params":[]}`, + `{"jsonrpc":"2.0","id":28,"method":"eth_accounts","params":[]}`, + `{"jsonrpc":"2.0","id":29,"method":"eth_call","params":[{"from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x9184e72a","input":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}]}`, + `{"jsonrpc":"2.0","id":30,"method":"eth_estimateGas","params":[{"from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x9184e72a","input":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}]}`, } expected := []string{ - `{"jsonrpc":"2.0","id":1,"result":"0x0"}`, - `{"jsonrpc":"2.0","id":2,"result":"0x29a"}`, + `{"jsonrpc":"2.0","id":1,"result":"0x29a"}`, + `{"jsonrpc":"2.0","id":2,"result":"0x0"}`, `{"jsonrpc":"2.0","id":3,"result":false}`, - `{"jsonrpc":"2.0","id":4,"result":"0x65"}`, - `{"jsonrpc":"2.0","id":5,"result":"0x20a"}`, + `{"jsonrpc":"2.0","id":4,"result":"0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"}`, + `{"jsonrpc":"2.0","id":5,"result":"0x1dfd14000"}`, + `{"jsonrpc":"2.0","id":6,"result":"0x65"}`, + `{"jsonrpc":"2.0","id":7,"result":"0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"}`, + `{"jsonrpc":"2.0","id":8,"result":"0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"}`, + `{"jsonrpc":"2.0","id":9,"result":"0x10078e"}`, + `{"jsonrpc":"2.0","id":10,"result":{"blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2","blockNumber":"0x5daf3b","from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d","gas":"0xc350","gasPrice":"0x4a817c800","hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b","input":"0x3078363836353663366336663231","nonce":"0x15","to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb","transactionIndex":"0x40","value":"0xf3dbb76162000","type":"0x0","v":"0x25","r":"0x96","s":"0xfa"}}`, + `{"jsonrpc":"2.0","id":11,"result":{"blockHash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b","blockNumber":"0x5daf3b","from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d","gas":"0xc350","gasPrice":"0x4a817c800","hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b","input":"0x3078363836353663366336663231","nonce":"0x15","to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb","transactionIndex":"0x40","value":"0xf3dbb76162000","type":"0x0","v":"0x25","r":"0x96","s":"0xfa"}}`, + `{"jsonrpc":"2.0","id":12,"result":{"blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2","blockNumber":"0x5daf3b","from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d","gas":"0xc350","gasPrice":"0x4a817c800","hash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b","input":"0x3078363836353663366336663231","nonce":"0x15","to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb","transactionIndex":"0x40","value":"0xf3dbb76162000","type":"0x0","v":"0x25","r":"0x96","s":"0xfa"}}`, + `{"jsonrpc":"2.0","id":13,"result":{"blockHash":"0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2","blockNumber":"0x5daf3b","contractAddress":null,"cumulativeGasUsed":"0xc350","effectiveGasPrice":"0x4a817c800","from":"0xa7d9ddbe1f17865597fbd27ec712455208b6b76d","gasUsed":"0x9c40","logs":[],"logsBloom":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b","status":"0x1","to":"0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb","transactionHash":"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b","transactionIndex":"0x40","type":"0x2"}}`, + `{"jsonrpc":"2.0","id":14,"result":"0x9b1d35635cc34752ca54713bb99d38614f63c955"}`, + `{"jsonrpc":"2.0","id":15,"result":{"difficulty":"0x4ea3f27bc","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","gasLimit":"0x1388","gasUsed":"0x0","hash":"0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","mixHash":"0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843","nonce":"0x689056015818adbe","number":"0x1b4","parentHash":"0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","stateRoot":"0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d","timestamp":"0x55ba467c","totalDifficulty":"0x78ed983323d","transactions":[],"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","uncles":[]}}`, + `{"jsonrpc":"2.0","id":16,"result":{"difficulty":"0x4ea3f27bc","extraData":"0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32","gasLimit":"0x1388","gasUsed":"0x0","hash":"0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0xbb7b8287f3f0a933474a79eae42cbca977791171","mixHash":"0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843","nonce":"0x689056015818adbe","number":"0x1b4","parentHash":"0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x220","stateRoot":"0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d","timestamp":"0x55ba467c","totalDifficulty":"0x78ed983323d","transactions":[],"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","uncles":[]}}`, + `{"jsonrpc":"2.0","id":17,"result":"0x188aa"}`, + `{"jsonrpc":"2.0","id":18,"result":"0x20a"}`, + `{"jsonrpc":"2.0","id":19,"result":"0x0"}`, + `{"jsonrpc":"2.0","id":20,"result":"0x0"}`, + `{"jsonrpc":"2.0","id":21,"result":[{"address":"0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d","topics":["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"],"data":"0x000000","blockNumber":"0x1b4","transactionHash":"0x00df829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf","transactionIndex":"0x0","blockHash":"0x008216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d","logIndex":"0x1","removed":false}]}`, + `{"jsonrpc":"2.0","id":22,"result":"filter0"}`, + `{"jsonrpc":"2.0","id":23,"result":true}`, + `{"jsonrpc":"2.0","id":24,"result":[{"address":"0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d","topics":["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"],"data":"0x000000","blockNumber":"0x1b4","transactionHash":"0x00df829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf","transactionIndex":"0x0","blockHash":"0x008216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d","logIndex":"0x1","removed":false}]}`, + `{"jsonrpc":"2.0","id":25,"result":[{"address":"0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d","topics":["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"],"data":"0x000000","blockNumber":"0x1b4","transactionHash":"0x00df829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf","transactionIndex":"0x0","blockHash":"0x008216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d","logIndex":"0x1","removed":false}]}`, + `{"jsonrpc":"2.0","id":26,"result":"block_filter"}`, + `{"jsonrpc":"2.0","id":27,"result":"pending_tx_filter"}`, + `{"jsonrpc":"2.0","id":28,"result":["0x407d73d8a49eeb85d32cf465507dd71d507100c1"]}`, + `{"jsonrpc":"2.0","id":29,"result":"0x00010203040506070809"}`, + `{"jsonrpc":"2.0","id":30,"result":"0x69"}`, } for i, request := range requests { resp := rpcRequest(url, request, "origin", "test.com")