-
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 recovery_address tests
- Loading branch information
1 parent
97134e7
commit 5b87a3f
Showing
5 changed files
with
137 additions
and
225 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
diem-move/diem-framework/core/transactional-tests/recovery_address/basics.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,19 @@ | ||
processed 11 tasks | ||
|
||
task 5 'run'. lines 45-48: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 775 | ||
|
||
task 6 'run'. lines 49-52: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 1285 | ||
|
||
task 7 'run'. lines 53-58: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 1031 | ||
|
||
task 8 'run'. lines 59-64: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 1285 | ||
|
||
task 9 'run'. lines 65-70: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 519 | ||
|
||
task 10 'run'. lines 71-71: | ||
Error: Failed to execute transaction. VMStatus: status ABORTED of type Execution with sub status 7 |
71 changes: 71 additions & 0 deletions
71
diem-move/diem-framework/core/transactional-tests/recovery_address/basics.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,71 @@ | ||
//# init --parent-vasps Parent1 Parent2 | ||
//# --addresses Child1=0xe42bd8dd8e9a3c5cdcb0a99619884fa1 | ||
//# Child2=0xdd00316615da8ef1b1114c6a9f20cd8a | ||
//# --private-keys Child1=915d621309cf25b9ae00c7ea7d2a2e99dcd77a2b71b79a5cf44c0291d8bdce6f | ||
//# Child2=75f1fbb7f1bc78e9de643ee11589c92a53ee616de15cdad0cc48f89024b55a4b | ||
|
||
|
||
|
||
// === Setup === | ||
|
||
//# run --signers Parent1 | ||
//# --type-args 0x1::XUS::XUS | ||
//# --args @Child1 | ||
//# x"e59531e507f309f5731a67600c845078" | ||
//# false | ||
//# 0 | ||
//# -- 0x1::AccountCreationScripts::create_child_vasp_account | ||
|
||
//# run --signers Parent1 | ||
//# --type-args 0x1::XUS::XUS | ||
//# --args @Child2 | ||
//# x"189804b7934e02fd0e57e66977819e81" | ||
//# false | ||
//# 0 | ||
//# -- 0x1::AccountCreationScripts::create_child_vasp_account | ||
|
||
|
||
|
||
// === Intended usage === | ||
|
||
// Make child1 a recovery address. | ||
// | ||
//# run --signers Child1 -- 0x1::AccountAdministrationScripts::create_recovery_address | ||
|
||
// Delegate parent1's key to child1. | ||
// | ||
//# run --signers Parent1 --args @Child1 -- 0x1::AccountAdministrationScripts::add_recovery_rotation_capability | ||
|
||
|
||
|
||
// ==== Abort cases === | ||
|
||
// Delegating parent2's key to child1 should abort because they are different VASPs. | ||
// | ||
//# run --signers Parent2 --args @Child1 -- 0x1::AccountAdministrationScripts::add_recovery_rotation_capability | ||
|
||
// Delegating parent2's key to an account without a RecoveryAddress resource should abort. | ||
// | ||
//# run --signers Parent2 --args 0x3333 -- 0x1::AccountAdministrationScripts::add_recovery_rotation_capability | ||
|
||
// Trying to recover an account that hasn't delegated its KeyRotationCapability to a recovery. | ||
// | ||
//# run --signers Child2 | ||
//# --args @Child1 @Child2 x"7013b6ed7dde3cfb1251db1b04ae9cd7853470284085693590a75def645a926d" | ||
//# -- 0x1::AccountAdministrationScripts::rotate_authentication_key_with_recovery_address | ||
|
||
// Trying to recover from an account without a RecoveryAddress resource should abort. | ||
// | ||
//# run --signers Child1 | ||
//# --args @Child2 @Child1 x"7013b6ed7dde3cfb1251db1b04ae9cd7853470284085693590a75def645a926d" | ||
//# -- 0x1::AccountAdministrationScripts::rotate_authentication_key_with_recovery_address | ||
|
||
// Parent1 shouldn't be able to rotate child1's address. | ||
// | ||
//# run --signers Parent1 | ||
//# --args @Child1 @Child1 x"7013b6ed7dde3cfb1251db1b04ae9cd7853470284085693590a75def645a926d" | ||
//# -- 0x1::AccountAdministrationScripts::rotate_authentication_key_with_recovery_address | ||
|
||
// A non-vasp can't create a recovery address | ||
// | ||
//# run --signers TreasuryCompliance -- 0x1::AccountAdministrationScripts::create_recovery_address |
4 changes: 4 additions & 0 deletions
4
.../diem-framework/core/transactional-tests/recovery_address/invalid_rotation_capability.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,4 @@ | ||
processed 4 tasks | ||
|
||
task 3 'run'. lines 33-43: | ||
Error: Transaction discarded. VMStatus: status ABORTED of type Execution with sub status 263 |
43 changes: 43 additions & 0 deletions
43
...diem-framework/core/transactional-tests/recovery_address/invalid_rotation_capability.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 --parent-vasps Test Vasp1 Vasp2 | ||
|
||
// TODO: 1. Check if this test has the right name. | ||
// 2, Consider rewriting this as a unit test. | ||
|
||
//# publish | ||
module Test::Holder { | ||
struct Holder<T> has key { x: T } | ||
public fun hold<T: store>(account: &signer, x: T) { | ||
move_to(account, Holder<T> { x }); | ||
} | ||
|
||
public fun get<T: store>(addr: address): T | ||
acquires Holder { | ||
let Holder<T>{ x } = move_from<Holder<T>>(addr); | ||
x | ||
} | ||
} | ||
|
||
//# run --admin-script --signers DiemRoot Vasp1 | ||
script { | ||
use Test::Holder; | ||
use DiemFramework::DiemAccount; | ||
|
||
fun main(_dr: signer, account: signer) { | ||
Holder::hold(&account, DiemAccount::extract_key_rotation_capability(&account)); | ||
} | ||
} | ||
|
||
|
||
// Try to create a recovery address with an invalid key rotation capability. | ||
// | ||
//# run --admin-script --signers DiemRoot Vasp2 | ||
script { | ||
use Test::Holder; | ||
use DiemFramework::DiemAccount; | ||
use DiemFramework::RecoveryAddress; | ||
|
||
fun main(_dr: signer, account: signer) { | ||
let cap = Holder::get<DiemAccount::KeyRotationCapability>(@Vasp1); | ||
RecoveryAddress::publish(&account, cap); | ||
} | ||
} |
225 changes: 0 additions & 225 deletions
225
language/move-compiler/functional-tests/tests/diem/recovery_address/basics.move
This file was deleted.
Oops, something went wrong.