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

Dao integration test and upgrade mpm #95

Merged
merged 14 commits into from
Aug 29, 2022
Merged
1 change: 1 addition & 0 deletions Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.1.0"
StarcoinFramework = "0x1"
StarcoinAssociation = "0xA550C18"
VMReserved = "0x0"
SFT = "0x6bfb460477adf9dd0455d3de2fc7f211"
jolestar marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
UnitTest = {local = "./unit-test"}
3 changes: 2 additions & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
compiled_package_info:
package_name: StarcoinFramework
address_alias_instantiation:
SFT: "0x6bfb460477adf9dd0455d3de2fc7f211"
StarcoinAssociation: "0x0000000000000000000000000a550c18"
StarcoinFramework: "0x00000000000000000000000000000001"
VMReserved: "0x00000000000000000000000000000000"
Expand Down Expand Up @@ -300,7 +301,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 909CE74C85980EFA85EC499713FA015307F578F64A8BB1B25942B9F63440DBA4
source_digest: 4BE2C3DAD713C16B046DCCFE66CFB80BA4E5CBD7B6DAC4E1BEE5CFD9C884052A
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file modified build/StarcoinFramework/source_maps/Block.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/CheckpointScript.mvsm
Binary file not shown.
64 changes: 23 additions & 41 deletions integration-tests/account/basic.exp
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ processed 14 tasks
task 5 'run'. lines 30-41:
{
"gas_used": 139240,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 6 'run'. lines 44-55:
{
"gas_used": 43065,
"status": {
"Keep": {
"MoveAbort": [
{
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Account"
}
},
26119
]
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Account"
}
},
"abort_code": "26119"
}
}
}
Expand All @@ -30,64 +26,50 @@ task 7 'run'. lines 58-74:
{
"gas_used": 58850,
"status": {
"Keep": {
"MoveAbort": [
{
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Account"
}
},
26369
]
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Account"
}
},
"abort_code": "26369"
}
}
}

task 8 'run'. lines 76-95:
{
"gas_used": 129486,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 9 'run'. lines 98-110:
{
"gas_used": 154312,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 10 'run'. lines 112-121:
{
"gas_used": 11474,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 11 'run'. lines 123-135:
{
"gas_used": 396842,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 12 'run'. lines 138-147:
{
"gas_used": 20214,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 13 'run'. lines 150-159:
{
"gas_used": 52949,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}
16 changes: 4 additions & 12 deletions integration-tests/block/block_checkpoints.exp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,23 @@ processed 7 tasks
task 3 'run'. lines 157-166:
{
"gas_used": 442844,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 4 'run'. lines 168-179:
{
"gas_used": 73780,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 5 'run'. lines 182-192:
{
"gas_used": 565771,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}

task 6 'run'. lines 194-205:
{
"gas_used": 95873,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}
4 changes: 1 addition & 3 deletions integration-tests/block/block_metadata.exp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ processed 3 tasks
task 2 'run'. lines 5-15:
{
"gas_used": 16339,
"status": {
"Keep": "Executed"
}
"status": "Executed"
}
35 changes: 35 additions & 0 deletions integration-tests/block/checkpoints_test.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
processed 13 tasks

task 4 'run'. lines 9-27:
{
"gas_used": 114532,
"status": "Executed"
}

task 7 'run'. lines 33-46:
{
"gas_used": 532278,
"status": {
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Block"
}
},
"abort_code": "4609"
}
}
}

task 10 'run'. lines 53-64:
{
"gas_used": 577624,
"status": "Executed"
}

task 12 'run'. lines 68-81:
{
"gas_used": 103932,
"status": "Executed"
}
81 changes: 81 additions & 0 deletions integration-tests/block/checkpoints_test.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//# init -n dev --debug

//# faucet --addr alice

//# block --author=0x2 --timestamp 86420000

//# call-api chain.info

//# run --signers alice --args {{$.call-api[0].head.parent_hash}} --args {{$.call-api[0].head.state_root}}
script {
use StarcoinFramework::Block;
use StarcoinFramework::Debug;

fun checkpoint(_account: signer, parent_hash: vector<u8>, state_root: vector<u8>) {
let expect_parent_hash = Block::get_parent_hash();
Debug::print(&expect_parent_hash);
Debug::print(&parent_hash);
Debug::print(&state_root);
assert!( expect_parent_hash == parent_hash, 1001);

let current_block_number = Block::get_current_block_number();
Debug::print(&current_block_number);

Block::checkpoint();
}
}
// check: EXECUTED

//# block --author=0x2 --timestamp 86430000

//# call-api chain.get_block_by_hash ["{{$.call-api[0].head.block_hash}}",{"raw":true}]

//# run --signers alice --args {{$.call-api[1].raw.header}}

script {
use StarcoinFramework::Block;
use StarcoinFramework::Debug;

fun update(_account: signer, raw_header: vector<u8>) {
let current_block_number = Block::get_current_block_number();
Debug::print(&current_block_number);
Debug::print(&raw_header);
Block::update_state_root(raw_header);
}
}
// check: ABORT. reason: Block from call-api[0] is not in checkpoint, its parent is in.


//# block --author=0x3

//# call-api chain.get_block_by_hash ["{{$.call-api[0].head.parent_hash}}",{"raw":true}]

//# run --signers alice --args {{$.call-api[2].raw.header}}

script {
use StarcoinFramework::Block;
use StarcoinFramework::Debug;

fun update(_account: signer, raw_header: vector<u8>) {
Debug::print(&raw_header);
Block::update_state_root(raw_header);
}
}
// check: EXECUTED

//# call-api chain.get_block_by_hash ["{{$.call-api[0].head.parent_hash}}"]

//# run --signers alice --args {{$.call-api[3].header.state_root}}
script {
use StarcoinFramework::Block;
use StarcoinFramework::Debug;

fun latest(_account: signer, expect_state_root: vector<u8>) {
let (number, state_root) = Block::latest_state_root();
Debug::print(&number);
Debug::print(&state_root);
Debug::print(&expect_state_root);
assert!(state_root == expect_state_root, 1002)
}
}
// check: EXECUTED
Loading