forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[diem-transactional-tests] on-chain-config tests
- Loading branch information
1 parent
17b462b
commit c39a247
Showing
11 changed files
with
304 additions
and
338 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ove/diem-framework/core/transactional-tests/on_chain_config/change_publishing_options.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
processed 7 tasks | ||
|
||
task 3 'run'. lines 21-31: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 2 | ||
|
||
task 4 'block'. lines 34-36: | ||
Events: | ||
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6000200000000000000" } | ||
|
||
task 6 'publish'. lines 46-49: | ||
Error: Transaction discarded. VMStatus: status INVALID_MODULE_PUBLISHER of type Validation |
49 changes: 49 additions & 0 deletions
49
...ve/diem-framework/core/transactional-tests/on_chain_config/change_publishing_options.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//# init --validators Vivian --parent-vasps Alice | ||
|
||
// Changing the publishing option from Open to CustomScript | ||
// Step 1: Make sure we can publish module Alice::Foo at the beginning | ||
//# publish | ||
module Alice::Foo { | ||
public fun foo() {} | ||
} | ||
|
||
|
||
// Initially, any script is allowed. | ||
//# run --admin-script --signers DiemRoot DiemRoot | ||
script { | ||
use DiemFramework::DiemTransactionPublishingOption; | ||
fun main(dr: signer, _dr2: signer) { | ||
assert!(DiemTransactionPublishingOption::is_script_allowed(&dr, &x""), 100); | ||
} | ||
} | ||
|
||
// Turning off open scripts is a privileged operation. | ||
//# run --admin-script --signers DiemRoot Vivian | ||
script { | ||
use DiemFramework::DiemTransactionPublishingOption; | ||
fun main(_dr: signer, vv: signer) { | ||
DiemTransactionPublishingOption::set_open_script(&vv); | ||
} | ||
} | ||
|
||
// TODO: double check on `DiemTransactionPublishingOption::set_open_script`. | ||
// - The name seems confusing. | ||
// - Shall we send more transactions to test out its effects? | ||
|
||
|
||
//# block --proposer Vivian --time 2 | ||
|
||
// Step 2: Change option to CustomModule | ||
//# run --admin-script --signers DiemRoot DiemRoot | ||
script { | ||
use DiemFramework::DiemTransactionPublishingOption; | ||
|
||
fun main(dr: signer, _dr2: signer) { | ||
DiemTransactionPublishingOption::set_open_module(&dr, false) | ||
} | ||
} | ||
|
||
//# publish | ||
module Alice::Bar { | ||
public fun bar() {} | ||
} |
18 changes: 18 additions & 0 deletions
18
diem-move/diem-framework/core/transactional-tests/on_chain_config/disable_txes.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
processed 8 tasks | ||
|
||
task 1 'block'. lines 3-5: | ||
Events: | ||
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 0, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6000200000000000000" } | ||
|
||
task 3 'run'. lines 14-18: | ||
Error: Transaction discarded. VMStatus: status UNKNOWN_SCRIPT of type Validation | ||
|
||
task 4 'block'. lines 20-23: | ||
Events: | ||
ContractEvent { key: EventKey(11000000000000000000000000000000000000000a550c18), index: 1, type: Struct(StructTag { address: 00000000000000000000000000000001, module: Identifier("DiemBlock"), name: Identifier("NewBlockEvent"), type_params: [] }), event_data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6000300000000000000" } | ||
|
||
task 6 'run'. lines 34-36: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 2055 | ||
|
||
task 7 'run'. lines 37-43: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 2 |
43 changes: 43 additions & 0 deletions
43
diem-move/diem-framework/core/transactional-tests/on_chain_config/disable_txes.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//# init --validators Vivian --parent-vasps Alice | ||
|
||
//# block --proposer Vivian --time 2 | ||
|
||
// Disable txes from all accounts except DiemRoot. | ||
//# run --admin-script --signers DiemRoot DiemRoot | ||
script { | ||
use DiemFramework::DiemTransactionPublishingOption; | ||
fun main(dr: signer, _dr2: signer) { | ||
DiemTransactionPublishingOption::halt_all_transactions(&dr); | ||
} | ||
} | ||
// Sending allowlisted script from normal account fails | ||
//# run --signers Alice -- 0x1::AccountAdministrationScripts::rotate_authentication_key | ||
|
||
// TODO: module publishing doesn't seem to be halted. Is this intentional? | ||
// publish | ||
// module Alice::M {} | ||
|
||
//# block --proposer Vivian --time 3 | ||
|
||
|
||
// Re-enable. this also tests that sending from DiemRoot succeeds. | ||
//# run --admin-script --signers DiemRoot DiemRoot | ||
script { | ||
use DiemFramework::DiemTransactionPublishingOption; | ||
fun main(dr: signer, _dr2: signer) { | ||
DiemTransactionPublishingOption::resume_transactions(&dr); | ||
} | ||
} | ||
|
||
// Sending from normal account succeeds again. | ||
// Note: the transaction will still abort due to the bad key supplied. This is normal. | ||
//# run --signers Alice --args x"" -- 0x1::AccountAdministrationScripts::rotate_authentication_key | ||
|
||
// A normal account has insufficient privs to halt transactions. | ||
//# run --admin-script --signers DiemRoot Vivian | ||
script { | ||
use DiemFramework::DiemTransactionPublishingOption; | ||
fun main(dr: signer, vv: signer) { | ||
DiemTransactionPublishingOption::halt_all_transactions(&vv); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
diem-move/diem-framework/core/transactional-tests/on_chain_config/vm_config.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
processed 11 tasks | ||
|
||
task 4 'run'. lines 32-47: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 2 | ||
|
||
task 5 'run'. lines 48-61: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 7 | ||
|
||
task 10 'run'. lines 95-95: | ||
Error: Transaction discarded. VMStatus: status GAS_UNIT_PRICE_BELOW_MIN_BOUND of type Validation |
95 changes: 95 additions & 0 deletions
95
diem-move/diem-framework/core/transactional-tests/on_chain_config/vm_config.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//# init --parent-vasps Alice Bob | ||
|
||
// Dummy module for testing... | ||
//# publish | ||
module DiemRoot::Nop { | ||
public(script) fun nop() {} | ||
} | ||
|
||
// Give Alice some money to pay for transactions... | ||
//# run --type-args 0x1::XUS::XUS --signers DesignatedDealer --args @Alice 100000 x"" x"" | ||
//# -- 0x1::PaymentScripts::peer_to_peer_with_metadata | ||
|
||
// Give Bob some money to pay for transactions... | ||
//# run --type-args 0x1::XUS::XUS --signers DesignatedDealer --args @Bob 100000 x"" x"" | ||
//# -- 0x1::PaymentScripts::peer_to_peer_with_metadata | ||
|
||
// List of constants: | ||
// sliding nonce | ||
// global_memory_per_byte_cost | ||
// global_memory_per_byte_write_cost | ||
// min_transaction_gas_units | ||
// large_transaction_cutoff | ||
// intrinsic_gas_per_byte | ||
// maximum_number_of_gas_units | ||
// min_price_per_gas_unit | ||
// max_price_per_gas_unit | ||
// max_transaction_size_in_bytes | ||
// gas_unit_scaling_factor | ||
// default_account_size | ||
|
||
// Wrong sender. Should fail. | ||
//# run --args 0 | ||
//# 4 | ||
//# 9 | ||
//# 600 | ||
//# 600 | ||
//# 8 | ||
//# 4000000 | ||
//# 0 | ||
//# 10000 | ||
//# 4096 | ||
//# 1000 | ||
//# 800 | ||
//# --signers TreasuryCompliance | ||
//# -- 0x1::SystemAdministrationScripts::set_gas_constants | ||
|
||
// Min gas price greater than max gas price. Should fail. | ||
//# run --args 0 | ||
//# 4 | ||
//# 9 | ||
//# 600 | ||
//# 600 | ||
//# 8 | ||
//# 4000000 | ||
//# 10 | ||
//# 9 | ||
//# 4096 | ||
//# 1000 | ||
//# 800 | ||
//# --signers DiemRoot | ||
//# -- 0x1::SystemAdministrationScripts::set_gas_constants | ||
|
||
//# run --signers Alice --gas-price 1 --gas-currency XUS -- 0xA550C18::Nop::nop | ||
|
||
// Increase the min_transaction gas units and min_price_per_gas_unit | ||
//# run --args 0 | ||
//# 4 | ||
//# 9 | ||
//# 6000 | ||
//# 600 | ||
//# 8 | ||
//# 4000000 | ||
//# 1 | ||
//# 10000 | ||
//# 4096 | ||
//# 1000 | ||
//# 800 | ||
//# --signers DiemRoot | ||
//# -- 0x1::SystemAdministrationScripts::set_gas_constants | ||
|
||
//# run --signers Bob --gas-price 1 --gas-currency XUS -- 0xA550C18::Nop::nop | ||
|
||
//# run --admin-script --signers DiemRoot DiemRoot | ||
script { | ||
use DiemFramework::DiemAccount; | ||
use DiemFramework::XUS::XUS; | ||
|
||
fun main() { | ||
// Alice processed before the bump in min transaction gas units so should have more money left | ||
assert!(DiemAccount::balance<XUS>(@Bob) < DiemAccount::balance<XUS>(@Alice), 42); | ||
} | ||
} | ||
|
||
// Can't process a transaction now with a gas price of zero since the lower bound was also changed. | ||
//# run --signers Alice --gas-price 0 --gas-currency XUS -- 0xA550C18::Nop::nop |
Oops, something went wrong.