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] migrate transaction_fee tests
- Loading branch information
1 parent
bc3d0d8
commit 41ba47b
Showing
9 changed files
with
192 additions
and
183 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
diem-move/diem-framework/core/tests/TransactionFeeTests.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,18 @@ | ||
#[test_only] | ||
module DiemFramework::TransactionFeeTests { | ||
use DiemFramework::TransactionFee; | ||
use DiemFramework::Genesis; | ||
|
||
#[test(tc = @TreasuryCompliance, dr = @DiemRoot)] | ||
#[expected_failure(abort_code = 1)] | ||
fun cannot_initialize_after_genesis(tc: signer, dr: signer) { | ||
Genesis::setup(&dr, &tc); | ||
TransactionFee::initialize(&tc); | ||
} | ||
|
||
#[test(account = @0x100)] | ||
#[expected_failure(abort_code = 258)] | ||
fun cannot_initialize_as_non_tc(account: signer) { | ||
TransactionFee::initialize(&account); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../diem-framework/core/transactional-tests/transaction_fee/add_transaction_fee_currency.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,31 @@ | ||
processed 10 tasks | ||
|
||
task 1 'block'. lines 3-7: | ||
Events:{ | ||
key: 11000000000000000000000000000000000000000a550c18 | ||
seq_num: 0 | ||
type: 0x1::DiemBlock::NewBlockEvent | ||
data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6000300000000000000" | ||
} | ||
|
||
|
||
task 3 'block'. lines 29-29: | ||
Events:{ | ||
key: 11000000000000000000000000000000000000000a550c18 | ||
seq_num: 1 | ||
type: 0x1::DiemBlock::NewBlockEvent | ||
data: "0000000000000000c5e34b925cf6875fec02d4b77adbd2d6000400000000000000" | ||
} | ||
|
||
|
||
task 5 'run'. lines 39-47: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 5 | ||
|
||
task 6 'run'. lines 49-56: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 5 | ||
|
||
task 8 'run'. lines 67-74: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 6 | ||
|
||
task 9 'run'. lines 76-84: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 1 |
84 changes: 84 additions & 0 deletions
84
...diem-framework/core/transactional-tests/transaction_fee/add_transaction_fee_currency.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,84 @@ | ||
//# init --validators Vivian --parent-vasps Bob | ||
|
||
//# block --proposer Vivian --time 3 | ||
|
||
// TODO: see if we can replace some of the admin scripts with script function calls. | ||
|
||
// BEGIN: registration of a currency | ||
|
||
//# publish | ||
module DiemRoot::COIN { | ||
use Std::FixedPoint32; | ||
use DiemFramework::Diem; | ||
|
||
struct COIN has store { } | ||
|
||
public fun initialize(dr_account: &signer, tc_account: &signer) { | ||
// Register the COIN currency. | ||
Diem::register_SCS_currency<COIN>( | ||
dr_account, | ||
tc_account, | ||
FixedPoint32::create_from_rational(1, 2), // exchange rate to XDX | ||
1000000, // scaling_factor = 10^6 | ||
100, // fractional_part = 10^2 | ||
b"COIN", | ||
) | ||
} | ||
} | ||
|
||
//# block --proposer Vivian --time 4 | ||
|
||
//# run --admin-script --signers DiemRoot TreasuryCompliance | ||
script { | ||
use DiemRoot::COIN; | ||
fun main(dr: signer, tc: signer) { | ||
COIN::initialize(&dr, &tc); | ||
} | ||
} | ||
|
||
//# run --admin-script --signers DiemRoot DiemRoot | ||
script { | ||
use DiemFramework::TransactionFee; | ||
use DiemFramework::Diem; | ||
use DiemRoot::COIN::COIN; | ||
fun main() { | ||
TransactionFee::pay_fee(Diem::zero<COIN>()); | ||
} | ||
} | ||
|
||
//# run --admin-script --signers DiemRoot TreasuryCompliance | ||
script { | ||
use DiemFramework::TransactionFee; | ||
use DiemRoot::COIN::COIN; | ||
fun main(_dr: signer, tc: signer) { | ||
TransactionFee::burn_fees<COIN>(&tc); | ||
} | ||
} | ||
|
||
//# run --admin-script --signers DiemRoot TreasuryCompliance | ||
script { | ||
use DiemFramework::TransactionFee; | ||
use DiemRoot::COIN::COIN; | ||
fun main(_dr: signer, tc: signer) { | ||
TransactionFee::add_txn_fee_currency<COIN>(&tc); | ||
} | ||
} | ||
|
||
//# run --admin-script --signers DiemRoot TreasuryCompliance | ||
script { | ||
use DiemFramework::TransactionFee; | ||
use DiemRoot::COIN::COIN; | ||
fun main(_dr: signer, tc: signer) { | ||
TransactionFee::add_txn_fee_currency<COIN>(&tc); | ||
} | ||
} | ||
|
||
//# run --admin-script --signers DiemRoot TreasuryCompliance | ||
script { | ||
use DiemFramework::TransactionFee; | ||
use DiemFramework::XDX::XDX; | ||
fun main(dr: signer, tc: signer) { | ||
TransactionFee::add_txn_fee_currency<XDX>(&tc); | ||
TransactionFee::burn_fees<XDX>(&tc); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
diem-move/diem-framework/core/transactional-tests/transaction_fee/burn_collected_fees.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,29 @@ | ||
processed 7 tasks | ||
|
||
task 3 'run'. lines 12-13: | ||
Error: Failed to execute transaction. VMStatus: status OUT_OF_GAS of type Execution | ||
|
||
task 4 'view'. lines 15-15: | ||
key 0x1::DiemAccount::Balance<0x1::XUS::XUS> { | ||
coin: store 0x1::Diem::Diem<0x1::XUS::XUS> { | ||
value: 9300 | ||
} | ||
} | ||
|
||
task 5 'run'. lines 17-20: | ||
Events:{ | ||
key: 07000000000000000000000000000000000000000a550c18 | ||
seq_num: 0 | ||
type: 0x1::Diem::PreburnEvent | ||
data: "bc02000000000000035855530000000000000000000000000b1e55ed" | ||
} | ||
{ | ||
key: 06000000000000000000000000000000000000000a550c18 | ||
seq_num: 0 | ||
type: 0x1::Diem::BurnEvent | ||
data: "bc02000000000000035855530000000000000000000000000b1e55ed" | ||
} | ||
|
||
|
||
task 6 'run'. lines 21-22: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 1799 |
22 changes: 22 additions & 0 deletions
22
diem-move/diem-framework/core/transactional-tests/transaction_fee/burn_collected_fees.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,22 @@ | ||
//# init --parent-vasps Bob | ||
|
||
// Give Bob some money to pay for transactions... | ||
//# run --type-args 0x1::XUS::XUS --signers DesignatedDealer --args @Bob 10000 x"" x"" | ||
//# -- 0x1::PaymentScripts::peer_to_peer_with_metadata | ||
|
||
//# publish | ||
module DiemRoot::InfiniteLoop { | ||
public(script) fun run() { while (true) {} } | ||
} | ||
|
||
//# run --signers Bob --gas-budget 700 --gas-price 1 --gas-currency XUS | ||
//# -- 0xA550C18::InfiniteLoop::run | ||
|
||
//# view --address Bob --resource 0x1::DiemAccount::Balance<0x1::XUS::XUS> | ||
|
||
//# run --signers TreasuryCompliance --type-args 0x1::XUS::XUS --show-events | ||
//# -- 0x1::TreasuryComplianceScripts::burn_txn_fees | ||
|
||
// No txn fee balance left to burn so this should fail. | ||
//# run --signers TreasuryCompliance --type-args 0x1::XUS::XUS --show-events | ||
//# -- 0x1::TreasuryComplianceScripts::burn_txn_fees |
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
126 changes: 0 additions & 126 deletions
126
...ve-compiler/functional-tests/tests/diem/transaction_fee/add_transaction_fee_currency.move
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
language/move-compiler/functional-tests/tests/diem/transaction_fee/burn_collected_fees.move
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
language/move-compiler/functional-tests/tests/diem/transaction_fee/initialization.move
This file was deleted.
Oops, something went wrong.