Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration testing #38

Closed
Tracked by #14
devbugging opened this issue Feb 5, 2024 · 1 comment · Fixed by #41
Closed
Tracked by #14

Integration testing #38

devbugging opened this issue Feb 5, 2024 · 1 comment · Fixed by #41
Assignees
Milestone

Comments

@devbugging
Copy link
Contributor

devbugging commented Feb 5, 2024

Add integration testing that will setup all the EVM gateway components and engines and use the emulator and scripts to generate data, which will after the test is run be checked against the APIs to see if it was correctly handled.

To avoid conflicts with current work done on the main branch, we will first check the indexed data against storage APIs and then after getting the changes in the main, we will change querying to the RPC APIs.

We will have multiple test cases which will be able to run using a simple CLI comand: go run main.go --test {name} where the name of the test will select which case you want to run.
Initially we will just have a simple case where we submit couple of transactions to cause the block executed events as well as transaction executed events.

@devbugging devbugging self-assigned this Feb 5, 2024
@devbugging devbugging removed this from 🌊 Flow 4D Feb 5, 2024
@devbugging devbugging removed this from 🌊 Flow 4D Feb 5, 2024
@devbugging devbugging changed the title Integration testing ]Integration testing Feb 5, 2024
@devbugging devbugging changed the title ]Integration testing Integration testing Feb 5, 2024
@m-Peter
Copy link
Collaborator

m-Peter commented Feb 7, 2024

Below is a list of ready-to-use JSON-RPC calls for some endpoints.

eth_sendRawTransaction

curl -XPOST 'localhost:8545/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xb9015f02f9015b82029a80808083124f808080b901086060604052341561000f57600080fd5b60eb8061001d6000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063c6888fa1146044575b600080fd5b3415604e57600080fd5b606260048080359060200190919050506078565b6040518082815260200191505060405180910390f35b60007f24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da600783026040518082815260200191505060405180910390a16007820290509190505600a165627a7a7230582040383f19d9f65246752244189b02f56e8d0980ed44e7a56c0b200458caad20bb0029c001a0c0dfc8ed68e5e2522006ac4dc7b1c0c783328311b3e860658be1bab16728ed98a048ef3ec7ff2f13ebda39f01526254e3c7ab64feb0c574703555dba316b6a88e3"],"id":1}'

The transaction above is a contract deployment for:

contract Multiply7 {
    event Print(uint);

    function multiply(uint input) returns (uint) {
        Print(input * 7);
        return input * 7;
    }
}
curl -XPOST 'localhost:8545/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xb88c02f88982029a01808083124f809499466ed2e37b892a2ee3e9cd55a98b68f5735db280a4c6888fa10000000000000000000000000000000000000000000000000000000000000006c001a0f84168f821b427dc158c4d8083bdc4b43e178cf0977a2c5eefbcbedcc4e351b0a066a747a38c6c266b9dc2136523cef04395918de37773db63d574aabde59c12eb"],"id":2}'

The transaction above will call the multiply function, with an input of 6

curl -XPOST 'localhost:8545/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xb88c02f88982029a02808083124f809499466ed2e37b892a2ee3e9cd55a98b68f5735db280a4c6888fa10000000000000000000000000000000000000000000000000000000000000007c080a0409f5baa7622655f76f7f67c1bd8cc4cdd5a8e64fab881d78c47d9d73e907befa04981b65452d66beeb80527f3e8d3d0bf18aa21cfbd9a0c5ee749192d43d72d95"],"id":3}'

The transaction above will call the multiply function, with an input of 7

eth_call

curl -XPOST 'localhost:8545/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0x658bdf435d810c91414ec09147daa6db62406379","to":"0x99466ed2e37b892a2ee3e9cd55a98b68f5735db2","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x0","input":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}],"id":4}'

The above JSON-RPC call with call the multiply function also, with an input of 6
Note: this is a read-only call, does not affect the blockchain state and does not raise any logs.

eth_getLogs

curl -XPOST 'localhost:8545/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":["0x24abdb5865df5079dcc5ac590ff6f01d5c16edbc5fab4e195d9febd1114503da"]}],"id":5}'

The above JSON-RPC call will return the logs that match a given topic, which in this case searches for the Print event from the Multiply7 solidity contract.

eth_getTransactionCount

curl -XPOST 'localhost:8545/rpc' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x658Bdf435d810C91414eC09147DAA6DB62406379","latest"],"id":6}'

The above JSON-RPC call will return the number of transactions for a given address.

@m-Peter m-Peter added this to the Flow-EVM-M2 milestone Feb 14, 2024
@github-project-automation github-project-automation bot moved this to ✅ Done in 🌊 Flow 4D Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants