From 788234e1a2c210234e25a751b75af340a1e60e58 Mon Sep 17 00:00:00 2001 From: jolestar Date: Wed, 17 Aug 2022 00:08:24 +0800 Subject: [PATCH 1/2] [mpm] Fix mpm integration test call api state.get_with_proof_by_root_raw --- vm/starcoin-transactional-test-harness/src/context.rs | 1 + .../tests/cases/call_api_cmd.exp | 6 +++--- .../tests/cases/call_api_cmd.move | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vm/starcoin-transactional-test-harness/src/context.rs b/vm/starcoin-transactional-test-harness/src/context.rs index 75ba858b4e..ca6813b153 100644 --- a/vm/starcoin-transactional-test-harness/src/context.rs +++ b/vm/starcoin-transactional-test-harness/src/context.rs @@ -139,6 +139,7 @@ impl ForkContext { self.storage.apply_write_set(write_set)?; let state_root = self.storage.commit()?; *self.state_root.lock().unwrap() = state_root; + self.storage.flush()?; Ok(()) } } diff --git a/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp b/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp index df402e5079..3c7b36901b 100644 --- a/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp +++ b/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp @@ -1,7 +1,7 @@ -processed 5 tasks +processed 6 tasks -task 4 'run'. lines 9-16: +task 5 'run'. lines 11-20: { - "gas_used": 10457, + "gas_used": 18995, "status": "Executed" } diff --git a/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.move b/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.move index 6faab89605..a2cdf2edcd 100644 --- a/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.move +++ b/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.move @@ -6,11 +6,14 @@ //# call-api chain.get_block_by_number [1] -//# run --signers creator --args {{$.call-api[0].header.number}}u64 --args {{$.call-api[0].header.block_hash}} +//# call-api state.get_with_proof_by_root_raw ["0x1/1/0x1::Account::Account","{{$.call-api[0].header.state_root}}"] + +//# run --signers creator --args {{$.call-api[0].header.number}}u64 --args {{$.call-api[0].header.block_hash}} --args {{$.call-api[1]}} script{ use StarcoinFramework::Vector; - fun main(_sender: signer, block_number: u64, block_hash: vector){ + fun main(_sender: signer, block_number: u64, block_hash: vector, state_proof: vector){ assert!(block_number == 1, 1000); assert!(Vector::length(&block_hash) == 32, 1001); + assert!(Vector::length(&state_proof) > 32, 1002); } } \ No newline at end of file From 36cdcd76163a986b5cf45daf4bb705b27649b79f Mon Sep 17 00:00:00 2001 From: jolestar Date: Wed, 17 Aug 2022 09:55:43 +0800 Subject: [PATCH 2/2] fixup --- .../tests/cases/call_api_cmd.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp b/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp index 3c7b36901b..f6f0cfa2c5 100644 --- a/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp +++ b/vm/starcoin-transactional-test-harness/tests/cases/call_api_cmd.exp @@ -1,7 +1,7 @@ processed 6 tasks -task 5 'run'. lines 11-20: +task 5 'run'. lines 11-19: { - "gas_used": 18995, + "gas_used": 15073, "status": "Executed" }