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

feat: implement test mode #224

Merged
merged 4 commits into from Jun 23, 2021
Merged

feat: implement test mode #224

merged 4 commits into from Jun 23, 2021

Conversation

zeroqn
Copy link
Contributor

@zeroqn zeroqn commented Jun 22, 2021

brief

This pr add test mode. In test mode, godwoken will stop produce new block and expose following jsonrpc methods

  • tests_produce_block
  • tests_should_produce_block
  • tests_get_global_state

To produce an new block, we make a jsonrpc to tests_produce_block.

config change

[test_mode]
enable = false

Add above entry to config.toml

jsonrpc

method tests_produce_block

Update on-chain global state. Right now only produce new block is supported.

method tests_should_produce_block

Whether this node has right to produce next block

method tests_get_global_state

Return on-chain global state

Example

echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "tests_produce_block",
    "params": ["none"]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
http://localhost:8119//

echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "tests_should_produce_block",
    "params": []
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
http://localhost:8119

echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "tests_get_global_state",
    "params": []
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
http://localhost:8119/

@zeroqn zeroqn requested a review from jjyr as a code owner June 22, 2021 01:48
expose test mode jsonrpc through tests_* method
crates/config/src/config.rs Outdated Show resolved Hide resolved
crates/rpc-server/src/registry.rs Show resolved Hide resolved
@jjyr jjyr merged commit 6bcd4ce into godwokenrises:master Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants