From 06d519cf67741525eded78f802895a990c197eb6 Mon Sep 17 00:00:00 2001 From: lpgeiger <1364012+lpgeiger@users.noreply.github.com> Date: Wed, 9 Jun 2021 10:22:53 -0400 Subject: [PATCH] Integration tests for onboarding and autopay (#548) * adds autopay, miner, onboard integration tests to ci * new account.json fixtures. * set chain id for swarm cases of onboarding * change timeout of integration test --- .github/workflows/integration.yaml | 59 +--- ol/cli/src/node/node.rs | 7 +- ol/fixtures/account/eve.account.json | 334 +++++++++++++++++- .../swarm/eve.fixed_recurring.account.json | 333 +++++++++++++++++ ol/fixtures/autopay/alice.autopay_batch.json | 2 +- .../alice.fixed_once.autopay_batch.json | 2 +- .../alice.fixed_recurring.autopay_batch.json | 12 + ol/fixtures/fixtures.md | 9 + ol/integration-tests/test-autopay.mk | 2 +- ol/integration-tests/test-onboard.mk | 107 ++++++ ol/onboard/src/commands/fix_cmd.rs | 1 + ol/onboard/src/commands/wizard_val_cmd.rs | 20 +- ol/txs/src/commands/autopay_batch_cmd.rs | 31 +- ol/txs/src/commands/create_validator_cmd.rs | 49 +-- ol/txs/src/submit_tx.rs | 13 +- ol/types/src/account.rs | 20 +- ol/types/src/autopay.rs | 45 +-- ol/types/src/config.rs | 4 +- 18 files changed, 922 insertions(+), 128 deletions(-) create mode 100644 ol/fixtures/account/swarm/eve.fixed_recurring.account.json create mode 100644 ol/fixtures/autopay/alice.fixed_recurring.autopay_batch.json create mode 100644 ol/fixtures/fixtures.md create mode 100644 ol/integration-tests/test-onboard.mk diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index a843739a11..4e8670897e 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -7,10 +7,10 @@ on: branches: [ main, 'release**' ] jobs: - mine: - name: Mining + integration: + name: Integration runs-on: self-hosted - timeout-minutes: 45 + timeout-minutes: 90 env: NODE_ENV: test TEST: y @@ -29,56 +29,19 @@ jobs: run: sudo apt-get install -y lld - name: Check branch run: echo "${{ steps.branch-name.outputs.current_branch }}" - - name: Swarm mining test + - name: Build sdlib + run: cargo r -p stdlib --release + - name: MINING run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-mining.mk test - autopay: - name: Autopay - runs-on: self-hosted - timeout-minutes: 45 - env: - NODE_ENV: test - TEST: y - steps: - - uses: actions/checkout@v2 - - name: Get branch names - id: branch-name - uses: tj-actions/branch-names@v4 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.46.0 - override: true - components: rustfmt, clippy - - name: Install deps - run: sudo apt-get install -y lld - - name: Check branch - run: echo "${{ steps.branch-name.outputs.current_branch }}" - - name: Swarm autopay percent-change + - name: AUTOPAY percent-change run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-autopay.mk test-percent-change - - name: Swarm autopay fixed-once + - name: AUTOPAY fixed-once run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-autopay.mk test-fixed-once - upgrade: - name: Stdlib Upgrade - runs-on: self-hosted - timeout-minutes: 45 - steps: - - uses: actions/checkout@v2 - - name: Get branch names - id: branch-name - uses: tj-actions/branch-names@v4 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.46.0 - override: true - components: rustfmt, clippy - - name: Install deps - run: sudo apt-get install -y lld - - name: Check branch - run: echo "${{ steps.branch-name.outputs.current_branch }}" + - name: ONBOARD + run: RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-onboard.mk test - name: File permissions run: sudo chmod -R 777 language/stdlib/ - - name: Swarm upgrade test + - name: UPGRADE run: BRANCH_NAME=${{ steps.branch-name.outputs.current_branch }} RUSTC_WRAPPER=sccache SOURCE_PATH=./ make -f ol/integration-tests/test-upgrade.mk test diff --git a/ol/cli/src/node/node.rs b/ol/cli/src/node/node.rs index 5124ebd933..6ca361ec91 100644 --- a/ol/cli/src/node/node.rs +++ b/ol/cli/src/node/node.rs @@ -5,6 +5,7 @@ use anyhow::Error; use cli::libra_client::LibraClient; use libra_config::config::NodeConfig; use libradb::LibraDB; +use std::path::PathBuf; use std::{process::Command, str}; use sysinfo::SystemExt; use sysinfo::{ProcessExt, ProcessStatus}; @@ -74,10 +75,10 @@ impl Node { } /// default node connection from configs - pub fn default_from_cfg(mut cfg: AppCfg) -> Node { + pub fn default_from_cfg(mut cfg: AppCfg, swarm_path: Option) -> Node { // NOTE: not intended for swarm. - let client = client::pick_client(None, &mut cfg).unwrap(); - Node::new(client, cfg, false) + let client = client::pick_client(swarm_path.clone(), &mut cfg).unwrap(); + Node::new(client, cfg, swarm_path.is_some()) } diff --git a/ol/fixtures/account/eve.account.json b/ol/fixtures/account/eve.account.json index 9f310bf462..3ed01a549c 100644 --- a/ol/fixtures/account/eve.account.json +++ b/ol/fixtures/account/eve.account.json @@ -1 +1,333 @@ -{"block_zero":{"height":0,"elapsed_secs":3,"preimage":"2bffcbd0e9016013cb8ca78459f69d2b3dc18d1cf61faac6ac70e3a63f062e4b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006578706572696d656e74616c6400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050726f74657374732072616765206163726f737320746865206e6174696f6e","proof":"0064c189e2b6d13c362bf9b2fa7ab2c4755cea2935ea42662b5bf03948e5f9cb0a53b0540094553bbfdb7557264b992ec8cabe30921ff20b26185fc6972a01f0ed500965d7a346ca9605940fe42be17a885f3638108245473ddc427252abf5096d8000b15c33679dd718f5145dfba100468e3a814c561d0e64b3117cd70fd56d4cffa6350ab95e8aff6652e2594a22dcd177ddf438b10499a8dbfda5d7a1e6b3894c3624b522aa48f14ea4556c741a5c8b0242dcafe6fd8c23cdb518ffb613295670b6ebc07cf885b3e6749a510a2369d5a37156ff6483330e64890c6149d4d2b07f5cd117a7605bf6d481987f9441a79f0a11939d9f28c04f055a62124991983601000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"},"ow_human_name":"3DC18D1CF61FAAC6AC70E3A63F062E4B","op_address":"0E04E58B354EF058D08DD493F2352454","op_auth_key_prefix":"ecc59a4a0963f65b5eceb0fffa01ea99","op_consensus_pubkey":"cac7909e7941176e76c55ddcfae6a9c13e2be071593c82cac685e7c82d7ffe9d","op_validator_network_addresses":"010000000000000000000000003e250c101cb1e6efe6160d0efb958f48e4ba3b5a5ac468080135881b885f9baef0da93a2a0b993823448da4d8bf04172b7bf7e42e121fc370793fc55bec39d","op_fullnode_network_addresses":"2d04009de60f2a052318072029fa0229ff55e1307caf3e32f3f4d0f2cb322cbb5e6d264c1df92e7740e1c06f0800","op_fullnode_network_addresses_string":"/ip4/157.230.15.42/tcp/6179/ln-noise-ik/29fa0229ff55e1307caf3e32f3f4d0f2cb322cbb5e6d264c1df92e7740e1c06f/ln-handshake/0","op_human_name":"3DC18D1CF61FAAC6AC70E3A63F062E4B-oper","autopay_instructions":[{"uid":0,"note":"test balance","type_of":"PercentOfBalance","type_move":0,"value":12.34,"value_move":1234,"destination":"88E74DFED34420F2AD8032148280A84B","end_epoch":100,"duration_epochs":100}],"autopay_signed":[{"raw_txn":{"sender":"3DC18D1CF61FAAC6AC70E3A63F062E4B","sequence_number":0,"payload":{"Script":{"code":[161,28,235,11,1,0,0,0,6,1,0,6,3,6,25,5,31,22,7,53,93,8,146,1,16,6,162,1,10,0,0,0,1,0,2,1,3,0,0,0,2,4,1,2,0,0,5,3,4,0,0,6,1,4,0,0,7,2,5,0,1,3,1,6,12,1,5,6,6,12,3,2,5,3,3,0,1,1,3,5,1,3,8,65,117,116,111,80,97,121,50,6,69,114,114,111,114,115,6,83,105,103,110,101,114,13,105,110,118,97,108,105,100,95,115,116,97,116,101,10,97,100,100,114,101,115,115,95,111,102,18,99,114,101,97,116,101,95,105,110,115,116,114,117,99,116,105,111,110,14,101,110,97,98,108,101,95,97,117,116,111,112,97,121,10,105,115,95,101,110,97,98,108,101,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,8,233,3,0,0,0,0,0,0,0,3,6,30,10,0,17,1,12,6,10,6,17,4,32,3,8,5,22,10,0,17,3,10,6,17,4,7,0,17,0,12,8,12,7,11,7,3,22,11,0,1,11,8,39,11,0,10,1,10,2,10,3,10,4,10,5,17,2,2],"ty_args":[],"args":[{"U64":0},{"U8":0},{"Address":"88E74DFED34420F2AD8032148280A84B"},{"U64":100},{"U64":1234}]}},"max_gas_amount":10000,"gas_unit_price":1,"gas_currency_code":"GAS","expiration_timestamp_secs":1621122731,"chain_id":1},"authenticator":{"Ed25519":{"public_key":"9af2f5b59e5e396692b91ac996d36236f15c5b17a6bec1cbbfe6c9c031d76449","signature":"ec2ed1e5aef2088992d0371f10668747f72262d5d76d2de016b5b2fa5ae34407cae00e1158c18be884ba852c2c5da86ecfcff618b470c25a6c0fd1d56b533808"}}}]} \ No newline at end of file +{ + "block_zero": { + "height": 0, + "elapsed_secs": 2, + "preimage": "2bffcbd0e9016013cb8ca78459f69d2b3dc18d1cf61faac6ac70e3a63f062e4b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006578706572696d656e74616c6400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050726f74657374732072616765206163726f737320746865206e6174696f6e", + "proof": "0064c189e2b6d13c362bf9b2fa7ab2c4755cea2935ea42662b5bf03948e5f9cb0a53b0540094553bbfdb7557264b992ec8cabe30921ff20b26185fc6972a01f0ed500965d7a346ca9605940fe42be17a885f3638108245473ddc427252abf5096d8000b15c33679dd718f5145dfba100468e3a814c561d0e64b3117cd70fd56d4cffa6350ab95e8aff6652e2594a22dcd177ddf438b10499a8dbfda5d7a1e6b3894c3624b522aa48f14ea4556c741a5c8b0242dcafe6fd8c23cdb518ffb613295670b6ebc07cf885b3e6749a510a2369d5a37156ff6483330e64890c6149d4d2b07f5cd117a7605bf6d481987f9441a79f0a11939d9f28c04f055a62124991983601000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" + }, + "ow_human_name": "3DC18D1CF61FAAC6AC70E3A63F062E4B", + "op_address": "0E04E58B354EF058D08DD493F2352454", + "op_auth_key_prefix": "ecc59a4a0963f65b5eceb0fffa01ea99", + "op_consensus_pubkey": "cac7909e7941176e76c55ddcfae6a9c13e2be071593c82cac685e7c82d7ffe9d", + "op_validator_network_addresses": "010000000000000000000000003e250c101cb1e6efe6160d0efb958f48e4ba3b5a5ac468080135881b885f9baef0da93a2a0b993823448da4d8bf04172b7bf7e42e121fc370793fc55bec39d", + "op_fullnode_network_addresses": "2d04009de60f2a052318072029fa0229ff55e1307caf3e32f3f4d0f2cb322cbb5e6d264c1df92e7740e1c06f0800", + "op_fullnode_network_addresses_string": "/ip4/157.230.15.42/tcp/6179/ln-noise-ik/29fa0229ff55e1307caf3e32f3f4d0f2cb322cbb5e6d264c1df92e7740e1c06f/ln-handshake/0", + "op_human_name": "3DC18D1CF61FAAC6AC70E3A63F062E4B-oper", + "autopay_instructions": [ + { + "uid": 0, + "note": "test balance", + "type_of": "PercentOfBalance", + "type_move": 0, + "value": 12.34, + "value_move": 1234, + "destination": "88E74DFED34420F2AD8032148280A84B", + "end_epoch": 287, + "duration_epochs": 100 + } + ], + "autopay_signed": [ + { + "raw_txn": { + "sender": "3DC18D1CF61FAAC6AC70E3A63F062E4B", + "sequence_number": 0, + "payload": { + "Script": { + "code": [ + 161, + 28, + 235, + 11, + 1, + 0, + 0, + 0, + 6, + 1, + 0, + 6, + 3, + 6, + 25, + 5, + 31, + 22, + 7, + 53, + 93, + 8, + 146, + 1, + 16, + 6, + 162, + 1, + 10, + 0, + 0, + 0, + 1, + 0, + 2, + 1, + 3, + 0, + 0, + 0, + 2, + 4, + 1, + 2, + 0, + 0, + 5, + 3, + 4, + 0, + 0, + 6, + 1, + 4, + 0, + 0, + 7, + 2, + 5, + 0, + 1, + 3, + 1, + 6, + 12, + 1, + 5, + 6, + 6, + 12, + 3, + 2, + 5, + 3, + 3, + 0, + 1, + 1, + 3, + 5, + 1, + 3, + 8, + 65, + 117, + 116, + 111, + 80, + 97, + 121, + 50, + 6, + 69, + 114, + 114, + 111, + 114, + 115, + 6, + 83, + 105, + 103, + 110, + 101, + 114, + 13, + 105, + 110, + 118, + 97, + 108, + 105, + 100, + 95, + 115, + 116, + 97, + 116, + 101, + 10, + 97, + 100, + 100, + 114, + 101, + 115, + 115, + 95, + 111, + 102, + 18, + 99, + 114, + 101, + 97, + 116, + 101, + 95, + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 14, + 101, + 110, + 97, + 98, + 108, + 101, + 95, + 97, + 117, + 116, + 111, + 112, + 97, + 121, + 10, + 105, + 115, + 95, + 101, + 110, + 97, + 98, + 108, + 101, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 3, + 8, + 233, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 6, + 30, + 10, + 0, + 17, + 1, + 12, + 6, + 10, + 6, + 17, + 4, + 32, + 3, + 8, + 5, + 22, + 10, + 0, + 17, + 3, + 10, + 6, + 17, + 4, + 7, + 0, + 17, + 0, + 12, + 8, + 12, + 7, + 11, + 7, + 3, + 22, + 11, + 0, + 1, + 11, + 8, + 39, + 11, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 17, + 2, + 2 + ], + "ty_args": [], + "args": [ + { + "U64": 0 + }, + { + "U8": 0 + }, + { + "Address": "88E74DFED34420F2AD8032148280A84B" + }, + { + "U64": 287 + }, + { + "U64": 1234 + } + ] + } + }, + "max_gas_amount": 10000, + "gas_unit_price": 1, + "gas_currency_code": "GAS", + "expiration_timestamp_secs": 1623113347, + "chain_id": 1 + }, + "authenticator": { + "Ed25519": { + "public_key": "9af2f5b59e5e396692b91ac996d36236f15c5b17a6bec1cbbfe6c9c031d76449", + "signature": "c1040f8fc13732a50cc39139d972baba2bfe64e4f8bd58c6a91cd125cc8853c94b995165f101f8cd20ca11b783daa3aeb7f3eafa1ec22fda82a8b37b72e8b70b" + } + } + } + ] +} \ No newline at end of file diff --git a/ol/fixtures/account/swarm/eve.fixed_recurring.account.json b/ol/fixtures/account/swarm/eve.fixed_recurring.account.json new file mode 100644 index 0000000000..45fcb1d02e --- /dev/null +++ b/ol/fixtures/account/swarm/eve.fixed_recurring.account.json @@ -0,0 +1,333 @@ +{ + "block_zero": { + "height": 0, + "elapsed_secs": 2, + "preimage": "2bffcbd0e9016013cb8ca78459f69d2b3dc18d1cf61faac6ac70e3a63f062e4b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006578706572696d656e74616c6400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000061736664", + "proof": "00348273ad10156b7cb32180f0e9dff562bc3e9301a0170f480175afeed5d8fcca52f9471dd5faf6d3c79048da7e0418037d3484c8a243b5fc788c5d51703a04d1eadc8d86446fba04d9e5b2688e804f08f70ce5d2da022d16aca54f383d195b0d170ad4e3cfa70482a3269669081afd5daa556b9f2caebdd97c46e170546de012ffe97a88a2883f1c25861b5fcaea1310af3cf459be12f6be5a9075ca10c2ce34d2a48730c87965ed6c90434f02a357f94018a64e30c6b448e85a6bad19a0ec1a430079404447cf97600ef3983fc3d2568fdcbae0739277b33c47712b3b0d1bf0e0ae166524271ce997c6d63cda8f055fa26b4bb35d183368b05a8434379e02d00d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" + }, + "ow_human_name": "3DC18D1CF61FAAC6AC70E3A63F062E4B", + "op_address": "0E04E58B354EF058D08DD493F2352454", + "op_auth_key_prefix": "ecc59a4a0963f65b5eceb0fffa01ea99", + "op_consensus_pubkey": "cac7909e7941176e76c55ddcfae6a9c13e2be071593c82cac685e7c82d7ffe9d", + "op_validator_network_addresses": "010000000000000000000000003e250c1024b483cfe6160d0efb958f48e4ba3b5a5ac468080135881b885f9baef0da93a2a0b993823448da4d8bf041b65fc96b964444b6db1ffa24fb327882", + "op_fullnode_network_addresses": "2d0400a5e36a0a052318072029fa0229ff55e1307caf3e32f3f4d0f2cb322cbb5e6d264c1df92e7740e1c06f0800", + "op_fullnode_network_addresses_string": "/ip4/165.227.106.10/tcp/6179/ln-noise-ik/29fa0229ff55e1307caf3e32f3f4d0f2cb322cbb5e6d264c1df92e7740e1c06f/ln-handshake/0", + "op_human_name": "3DC18D1CF61FAAC6AC70E3A63F062E4B-oper", + "autopay_instructions": [ + { + "uid": 0, + "note": "recurring", + "type_of": "FixedRecurring", + "type_move": 2, + "value": 1.0, + "value_move": 1000000, + "destination": "88E74DFED34420F2AD8032148280A84B", + "end_epoch": 289, + "duration_epochs": 100 + } + ], + "autopay_signed": [ + { + "raw_txn": { + "sender": "3DC18D1CF61FAAC6AC70E3A63F062E4B", + "sequence_number": 0, + "payload": { + "Script": { + "code": [ + 161, + 28, + 235, + 11, + 1, + 0, + 0, + 0, + 6, + 1, + 0, + 6, + 3, + 6, + 25, + 5, + 31, + 22, + 7, + 53, + 93, + 8, + 146, + 1, + 16, + 6, + 162, + 1, + 10, + 0, + 0, + 0, + 1, + 0, + 2, + 1, + 3, + 0, + 0, + 0, + 2, + 4, + 1, + 2, + 0, + 0, + 5, + 3, + 4, + 0, + 0, + 6, + 1, + 4, + 0, + 0, + 7, + 2, + 5, + 0, + 1, + 3, + 1, + 6, + 12, + 1, + 5, + 6, + 6, + 12, + 3, + 2, + 5, + 3, + 3, + 0, + 1, + 1, + 3, + 5, + 1, + 3, + 8, + 65, + 117, + 116, + 111, + 80, + 97, + 121, + 50, + 6, + 69, + 114, + 114, + 111, + 114, + 115, + 6, + 83, + 105, + 103, + 110, + 101, + 114, + 13, + 105, + 110, + 118, + 97, + 108, + 105, + 100, + 95, + 115, + 116, + 97, + 116, + 101, + 10, + 97, + 100, + 100, + 114, + 101, + 115, + 115, + 95, + 111, + 102, + 18, + 99, + 114, + 101, + 97, + 116, + 101, + 95, + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 14, + 101, + 110, + 97, + 98, + 108, + 101, + 95, + 97, + 117, + 116, + 111, + 112, + 97, + 121, + 10, + 105, + 115, + 95, + 101, + 110, + 97, + 98, + 108, + 101, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 3, + 8, + 233, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 6, + 30, + 10, + 0, + 17, + 1, + 12, + 6, + 10, + 6, + 17, + 4, + 32, + 3, + 8, + 5, + 22, + 10, + 0, + 17, + 3, + 10, + 6, + 17, + 4, + 7, + 0, + 17, + 0, + 12, + 8, + 12, + 7, + 11, + 7, + 3, + 22, + 11, + 0, + 1, + 11, + 8, + 39, + 11, + 0, + 10, + 1, + 10, + 2, + 10, + 3, + 10, + 4, + 10, + 5, + 17, + 2, + 2 + ], + "ty_args": [], + "args": [ + { + "U64": 0 + }, + { + "U8": 2 + }, + { + "Address": "88E74DFED34420F2AD8032148280A84B" + }, + { + "U64": 289 + }, + { + "U64": 1000000 + } + ] + } + }, + "max_gas_amount": 10000, + "gas_unit_price": 1, + "gas_currency_code": "GAS", + "expiration_timestamp_secs": 1623803116, + "chain_id": 4 + }, + "authenticator": { + "Ed25519": { + "public_key": "9af2f5b59e5e396692b91ac996d36236f15c5b17a6bec1cbbfe6c9c031d76449", + "signature": "48a6da37c40b7aeb4e1095de1a7517bd157af3a48d47c676c29d02a9b0e05126630ca7486a72f537595e2bde81c28d5308318e88c764ddb6cc6f75c21927900d" + } + } + } + ] +} \ No newline at end of file diff --git a/ol/fixtures/autopay/alice.autopay_batch.json b/ol/fixtures/autopay/alice.autopay_batch.json index 113b92d8ee..934577fee3 100644 --- a/ol/fixtures/autopay/alice.autopay_batch.json +++ b/ol/fixtures/autopay/alice.autopay_batch.json @@ -1,7 +1,7 @@ { "autopay_instructions": [ { - "note": "test balance", + "note": "balance", "uid": 0, "destination": "88E74DFED34420F2AD8032148280A84B", "type_of": "PercentOfBalance", diff --git a/ol/fixtures/autopay/alice.fixed_once.autopay_batch.json b/ol/fixtures/autopay/alice.fixed_once.autopay_batch.json index 22ebe7d377..d47221f2f8 100644 --- a/ol/fixtures/autopay/alice.fixed_once.autopay_batch.json +++ b/ol/fixtures/autopay/alice.fixed_once.autopay_batch.json @@ -1,7 +1,7 @@ { "autopay_instructions": [ { - "note": "test balance", + "note": "once", "uid": 0, "destination": "88E74DFED34420F2AD8032148280A84B", "type_of": "FixedOnce", diff --git a/ol/fixtures/autopay/alice.fixed_recurring.autopay_batch.json b/ol/fixtures/autopay/alice.fixed_recurring.autopay_batch.json new file mode 100644 index 0000000000..6cba280333 --- /dev/null +++ b/ol/fixtures/autopay/alice.fixed_recurring.autopay_batch.json @@ -0,0 +1,12 @@ +{ + "autopay_instructions": [ + { + "note": "recurring", + "uid": 0, + "destination": "88E74DFED34420F2AD8032148280A84B", + "type_of": "FixedRecurring", + "value": 1, + "duration_epochs": 100 + } + ] +} \ No newline at end of file diff --git a/ol/fixtures/fixtures.md b/ol/fixtures/fixtures.md new file mode 100644 index 0000000000..5d2592d275 --- /dev/null +++ b/ol/fixtures/fixtures.md @@ -0,0 +1,9 @@ + +## Account.json + +These fixtures simulate a new user config files. + +#### Swarm +For swarm, these files need to have +- chain-id=4 +- transaction expiration for autopay WAY in the future. Since the usual autopay tx expiry is 24h. \ No newline at end of file diff --git a/ol/integration-tests/test-autopay.mk b/ol/integration-tests/test-autopay.mk index 407841fe66..8b1439c835 100644 --- a/ol/integration-tests/test-autopay.mk +++ b/ol/integration-tests/test-autopay.mk @@ -1,7 +1,7 @@ SHELL=/usr/bin/env bash DATA_PATH = ${HOME}/.0L SWARM_TEMP = ${DATA_PATH}/swarm_temp -LOG=${DATA_PATH}/test-mining.log +LOG=${DATA_PATH}/test-autopay.log UNAME := $(shell uname) NODE_ENV=test diff --git a/ol/integration-tests/test-onboard.mk b/ol/integration-tests/test-onboard.mk new file mode 100644 index 0000000000..5dac606148 --- /dev/null +++ b/ol/integration-tests/test-onboard.mk @@ -0,0 +1,107 @@ +SHELL=/usr/bin/env bash +DATA_PATH = ${HOME}/.0L +SWARM_TEMP = ${DATA_PATH}/swarm_temp +LOG=${DATA_PATH}/test-onboard.log +UNAME := $(shell uname) + +NODE_ENV=test +TEST=y + +ifndef SOURCE_PATH +SOURCE_PATH = ${HOME}/libra +endif +MAKE_FILE = ${SOURCE_PATH}/ol/integration-tests/test-onboard.mk + +# alice +ifndef PERSONA +PERSONA=alice +endif + +MNEM="talent sunset lizard pill fame nuclear spy noodle basket okay critic grow sleep legend hurry pitch blanket clerk impose rough degree sock insane purse" + +NUM_NODES = 4 +EVE = 3DC18D1CF61FAAC6AC70E3A63F062E4B + +ONBOARD_FILE=eve.fixed_recurring.account.json + +START_TEXT = "To run the Libra CLI client" +SUCCESS_TEXT = "User transactions successfully relayed" + +# account.json fixtures generated with: +# cargo r -p onboard -- --swarm-path ./whatever val --upstream-peer http://167.172.248.37/ + +test: swarm check-swarm send-tx check-tx check-account-created check-transfer stop + +swarm: + @echo Building Swarm + rm -rf ${SWARM_TEMP} + mkdir ${SWARM_TEMP} + cd ${SOURCE_PATH} && cargo build -p libra-node -p cli + cd ${SOURCE_PATH} && NODE_ENV=test TEST=y cargo run -p libra-swarm -- --libra-node ${SOURCE_PATH}/target/debug/libra-node -c ${SWARM_TEMP} -n ${NUM_NODES} &> ${LOG} & + +stop: + killall libra-swarm libra-node miner ol | true + + +init: + @echo INIT + cd ${SOURCE_PATH} && cargo r -p ol -- --swarm-path ${SWARM_TEMP} --swarm-persona ${PERSONA} init --source-path ${SOURCE_PATH} + +tx: + @echo TX + cd ${SOURCE_PATH} && NODE_ENV=test TEST=y cargo r -p txs -- --swarm-path ${SWARM_TEMP} --swarm-persona ${PERSONA} create-validator -f ${SOURCE_PATH}/ol/fixtures/account/swarm/${ONBOARD_FILE} + +resources: + cd ${SOURCE_PATH} && cargo run -p ol -- --swarm-path ${SWARM_TEMP} --swarm-persona ${PERSONA} --account ${EVE} query --resources + +balance: + cd ${SOURCE_PATH} && cargo run -p ol -- --swarm-path ${SWARM_TEMP} --swarm-persona ${PERSONA} --account 3DC18D1CF61FAAC6AC70E3A63F062E4B query --balance + +balance-bob: + cd ${SOURCE_PATH} && cargo run -p ol -- --account 88E74DFED34420F2AD8032148280A84B --swarm-path ${SWARM_TEMP} --swarm-persona ${PERSONA} query --balance + + +check-swarm: + @while [[ ${NOW} -le ${END} ]] ; do \ + if grep -q ${START_TEXT} ${LOG} ; then \ + break; \ + else \ + echo . ; \ + fi ; \ + echo "Sleeping for 5 secs" ; \ + sleep 5 ; \ + done + +send-tx: + PERSONA=alice make -f ${MAKE_FILE} init + PERSONA=alice make -f ${MAKE_FILE} tx &>> ${LOG} & + +check-tx: + @while [[ ${NOW} -le ${END} ]] ; do \ + if grep -q ${SUCCESS_TEXT} ${LOG} ; then \ + echo TX SUCCESS ; \ + break ; \ + else \ + echo . ; \ + fi ; \ + echo "Sleeping for 5 secs" ; \ + sleep 5 ; \ + done + +check-account-created: +# checks if there is any mention of BOB's account as a payee on EVE's account + PERSONA=alice make -f ${MAKE_FILE} resources | grep -e 'payee' + +check-transfer: +# swarm accounts start with a balance of 4 + @while [[ ${NOW} -le ${END} ]] ; do \ + if PERSONA=alice make -f ${MAKE_FILE} balance-bob | grep -e '5'; then \ + echo TX SUCCESS ; \ + break ; \ + else \ + echo . ; \ + fi ; \ + echo "Sleeping for 5 secs" ; \ + sleep 5 ; \ + done + \ No newline at end of file diff --git a/ol/onboard/src/commands/fix_cmd.rs b/ol/onboard/src/commands/fix_cmd.rs index 91ed190d5c..15b71093b5 100644 --- a/ol/onboard/src/commands/fix_cmd.rs +++ b/ol/onboard/src/commands/fix_cmd.rs @@ -50,6 +50,7 @@ pub fn migrate_account_json(cfg: &AppCfg) { &home_path, &cfg, &wallet, + false, // TODO: Do we need swarm case for this? ); let account_json_path = cfg.workspace.node_home.clone().join("account.json"); diff --git a/ol/onboard/src/commands/wizard_val_cmd.rs b/ol/onboard/src/commands/wizard_val_cmd.rs index 6940c555c6..f2f34f1190 100644 --- a/ol/onboard/src/commands/wizard_val_cmd.rs +++ b/ol/onboard/src/commands/wizard_val_cmd.rs @@ -5,6 +5,7 @@ use super::files_cmd; +use crate::entrypoint; use crate::prelude::app_config; use abscissa_core::{status_info, status_ok, Command, Options, Runnable}; use libra_genesis_tool::node_files; @@ -13,6 +14,7 @@ use libra_wallet::WalletLibrary; use ol::{commands::init_cmd, config::AppCfg}; use ol_keys::{scheme::KeyScheme, wallet}; use ol_types::block::Block; +use ol_types::config::IS_TEST; use ol_types::{account::ValConfigs, autopay::PayInstruction, config::TxType}; use reqwest::Url; use std::process::exit; @@ -54,6 +56,8 @@ impl Runnable for ValWizardCmd { // Note. `onboard` command DOES NOT READ CONFIGS FROM 0L.toml status_info!("\nValidator Config Wizard.", "Next you'll enter your mnemonic and some other info to configure your validator node and on-chain account. If you haven't yet generated keys, run the standalone keygen tool with 'ol keygen'.\n\nYour first 0L proof-of-work will be mined now. Expect this to take up to 15 minutes on modern CPUs.\n"); + + let entry_args = entrypoint::get_args(); // Get credentials from prompt let (authkey, account, wallet) = wallet::get_account_from_prompt(); @@ -101,6 +105,7 @@ impl Runnable for ValWizardCmd { home_path, &app_config, &wallet, + entry_args.swarm_path.as_ref().is_some() ); status_ok!( "\nAutopay transactions signed", @@ -179,6 +184,7 @@ pub fn get_autopay_batch( home_path: &PathBuf, cfg: &AppCfg, wallet: &WalletLibrary, + is_swarm: bool, ) -> (Option>, Option>) { let file_name = if template.is_some() { // assumes the template was downloaded from URL @@ -193,13 +199,19 @@ pub fn get_autopay_batch( Some(starting_epoch.clone()), ) .unwrap(); - let script_vec = autopay_batch_cmd::process_instructions(instr_vec.clone(), &starting_epoch); + let script_vec = autopay_batch_cmd::process_instructions(instr_vec.clone()); let url = cfg.what_url(false); let mut tx_params = - submit_tx::get_tx_params_from_toml(cfg.to_owned(), TxType::Miner, Some(wallet), url, None) + submit_tx::get_tx_params_from_toml(cfg.to_owned(), TxType::Miner, Some(wallet), url, None, is_swarm) .unwrap(); - // give the tx a very long expiration, 1 day. - let tx_expiration_sec = 24 * 60 * 60; + let tx_expiration_sec = if *IS_TEST { + // creating fixtures here, so give it near infinite expiry + 100 * 360 * 24 * 60 * 60 + } else { + // give the tx a very long expiration, 7 days. + 7 * 24 * 60 * 60 + }; + tx_params.tx_cost.user_tx_timeout = tx_expiration_sec; let txn_vec = autopay_batch_cmd::sign_instructions(script_vec, 0, &tx_params); (Some(instr_vec), Some(txn_vec)) diff --git a/ol/txs/src/commands/autopay_batch_cmd.rs b/ol/txs/src/commands/autopay_batch_cmd.rs index 701c44efd0..2b32bf2d93 100644 --- a/ol/txs/src/commands/autopay_batch_cmd.rs +++ b/ol/txs/src/commands/autopay_batch_cmd.rs @@ -6,8 +6,8 @@ use abscissa_core::{Command, Options, Runnable}; use libra_types::transaction::{Script, SignedTransaction}; use crate::{entrypoint, sign_tx::sign_tx, submit_tx::{tx_params_wrapper, batch_wrapper, TxParams}}; use dialoguer::Confirm; -use std::path::PathBuf; -use ol_types::{autopay::PayInstruction, config::{TxType, IS_CI}}; +use std::{path::PathBuf, process::exit}; +use ol_types::{autopay::PayInstruction, config::{TxType, IS_TEST}}; /// command to submit a batch of autopay tx from file #[derive(Command, Debug, Default, Options)] @@ -27,21 +27,34 @@ impl Runnable for AutopayBatchCmd { let epoch = crate::epoch::get_epoch(&tx_params); println!("The current epoch is: {}", epoch); let instructions = PayInstruction::parse_autopay_instructions(&self.autopay_batch_file, Some(epoch)).unwrap(); - let scripts = process_instructions(instructions, &epoch); + let scripts = process_instructions(instructions); batch_wrapper(scripts, &tx_params, entry_args.no_send, entry_args.save_path) - } } /// Process autopay instructions into scripts -pub fn process_instructions(instructions: Vec, starting_epoch: &u64) -> Vec