Skip to content

Commit

Permalink
[diem-framework] migrate block transactional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vgao1996 authored and bors-libra committed Dec 16, 2021
1 parent 0f6d7d2 commit 23d08cd
Show file tree
Hide file tree
Showing 27 changed files with 168 additions and 214 deletions.
4 changes: 4 additions & 0 deletions diem-move/diem-framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ dir-diff = "0.3.2"
[features]
default = []
fuzzing = ["diem-types/fuzzing"]

[[test]]
name = "transactional_tests"
harness = false
13 changes: 13 additions & 0 deletions diem-move/diem-framework/core/tests/DiemBlockTests.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[test_only]
module DiemFramework::DiemBlockTests {
use DiemFramework::Genesis;
use DiemFramework::DiemBlock;

// TODO: the error code doesn't seem correct, juding by the name of the test.
#[test(tc = @TreasuryCompliance, dr = @DiemRoot, account = @0x100)]
#[expected_failure(abort_code = 1)]
fun invalid_initialization_address(account: signer, tc: signer, dr: signer) {
Genesis::setup(&dr, &tc);
DiemBlock::initialize_block_metadata(&account);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
processed 5 tasks

task 1 'block'. lines 3-3:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d60040420f0000000000" }

task 4 'run'. lines 29-37:
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 514
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//# init --validators Vivian

//# block --proposer Vivian --time 1000000

//# run --admin-script
//# --signers DiemRoot
script{
use DiemFramework::DiemTimestamp;
use DiemFramework::DiemBlock;

fun main() {
assert!(DiemBlock::get_current_block_height() == 1, 73);
assert!(DiemTimestamp::now_microseconds() == 1000000, 76);
}
}

//# run --admin-script
//# --signers DiemRoot
script{
use DiemFramework::DiemTimestamp;

fun main() {
assert!(DiemTimestamp::now_microseconds() != 2000000, 77);
}
}

// TODO: this transaction looks weird. We should figure out what the intention is and decide
// what to do with it.
//# run --admin-script
//# --signers Vivian
script{
use DiemFramework::DiemTimestamp;

fun main(dr: signer, vv: signer) {
DiemTimestamp::update_global_time(&vv, @Vivian, 20);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
processed 10 tasks

task 1 'block'. lines 3-3:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d60000e1f50500000000" }

task 2 'publish'. lines 5-6:
Error: Transaction discarded. VMStatus: status TRANSACTION_EXPIRED of type Validation

task 3 'publish'. lines 8-9:
Error: Transaction discarded. VMStatus: status TRANSACTION_EXPIRED of type Validation

task 6 'block'. lines 17-17:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 1, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6004023050600000000" }

task 8 'publish'. lines 22-23:
Error: Transaction discarded. VMStatus: status TRANSACTION_EXPIRED of type Validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//# init --parent-vasps Alice --validators Vivian

//# block --proposer Vivian --time 100000000

//# publish --expiration 99
module Alice::M1 {}

//# publish --expiration 100
module Alice::M2 {}

//# publish --expiration 101
module Alice::M3 {}

//# publish --expiration 86500
module Alice::M4 {}

//# block --proposer Vivian --time 101000000

//# publish --expiration 86500
module Alice::M5 {}

//# publish --expiration 101
module Alice::M6 {}

//# publish --expiration 18446744073710
module Alice::M7 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
processed 6 tasks

task 2 'block'. lines 12-12:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d60000e1f50500000000" }

task 4 'block'. lines 25-25:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 1, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6004023050600000000" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! account: vivian, 1000000, 0, validator
//! new-transaction
//# init --validators Vivian

//# run --admin-script --signers DiemRoot
script{
use DiemFramework::DiemBlock;
fun main() {
Expand All @@ -9,11 +9,9 @@ fun main() {
}
}

//! block-prologue
//! proposer: vivian
//! block-time: 100000000
//# block --proposer Vivian --time 100000000

//! new-transaction
//# run --admin-script --signers DiemRoot
script{
use DiemFramework::DiemBlock;
use DiemFramework::DiemTimestamp;
Expand All @@ -24,11 +22,9 @@ fun main() {
}
}

//! block-prologue
//! proposer: vivian
//! block-time: 101000000
//# block --proposer Vivian --time 101000000

//! new-transaction
//# run --admin-script --signers DiemRoot
script{
use DiemFramework::DiemBlock;
use DiemFramework::DiemTimestamp;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
processed 4 tasks

task 1 'block'. lines 3-3:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d60040420f0000000000" }

task 3 'block'. lines 16-16:
Error: status UNEXPECTED_ERROR_FROM_KNOWN_MOVE_FUNCTION of type Invariant violation
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//# init --parent-vasps Alice --validators Vivian

//# block --proposer Vivian --time 1000000

//# run --signers DiemRoot --admin-script
script{
use DiemFramework::DiemBlock;
use DiemFramework::DiemTimestamp;

fun main() {
assert!(DiemBlock::get_current_block_height() == 1, 77);
assert!(DiemTimestamp::now_microseconds() == 1000000, 78);
}
}

//# block --proposer Alice --time 1000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
processed 4 tasks

task 1 'block'. lines 3-3:
Events:
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d60000e1f50500000000" }

task 3 'block'. lines 16-16:
Error: status UNEXPECTED_ERROR_FROM_KNOWN_MOVE_FUNCTION of type Invariant violation
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
//! account: vivian, 1000000, 0, validator
//# init --validators Vivian

//! block-prologue
//! proposer: vivian
//! block-time: 100000000
//# block --proposer Vivian --time 100000000

//! new-transaction
//# run --signers DiemRoot --admin-script
script{
use DiemFramework::DiemBlock;
use DiemFramework::DiemTimestamp;
Expand All @@ -15,6 +13,4 @@ fun main() {
}
}

//! block-prologue
//! proposer: vivian
//! block-time: 11000000
//# block --proposer Vivian --time 90000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'block'. lines 1-1:
Error: status UNEXPECTED_ERROR_FROM_KNOWN_MOVE_FUNCTION of type Invariant violation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//# block --proposer 0x0 --time 1000000
6 changes: 6 additions & 0 deletions diem-move/diem-framework/tests/transactional_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

use diem_transactional_test_harness::run_test;

datatest_stable::harness!(run_test, "core/transactional-tests", r".*\.(mvir|move)$");

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 23d08cd

Please sign in to comment.