Skip to content

Commit e6f011b

Browse files
authored
feat(iota-adapter-transactional-tests): add a test with an event in the authenticator (#9696)
# Description of change Added a transactional test with an event in the authenticator. ## Links to any relevant issues fixes #9667
1 parent 11d3554 commit e6f011b

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// an event is emitted during authentication
5+
6+
//# init --addresses test=0x0 simple_abstract_account=0x0 --accounts A
7+
8+
//# publish-dependencies --paths crates/iota-adapter-transactional-tests/data/account_abstraction/simple_abstract_account.move
9+
10+
//# publish --sender A --dependencies simple_abstract_account
11+
module test::authenticate;
12+
13+
use iota::auth_context::AuthContext;
14+
use simple_abstract_account::abstract_account::AbstractAccount;
15+
use std::ascii;
16+
17+
public struct AuthenticationSuccessEvent has copy, drop {
18+
message: ascii::String,
19+
}
20+
21+
#[authenticator]
22+
public fun authenticate_with_event(
23+
_account: &AbstractAccount,
24+
_auth_ctx: &AuthContext,
25+
_ctx: &TxContext,
26+
) {
27+
iota::event::emit(AuthenticationSuccessEvent {
28+
message: ascii::string(b"Hello World! Authentication succeeded."),
29+
});
30+
}
31+
32+
//# init-abstract-account --sender A --package-metadata object(3,1) --inputs "authenticate" "authenticate_with_event" --create-function simple_abstract_account::abstract_account::create --account-type simple_abstract_account::abstract_account::AbstractAccount
33+
34+
//# view-object 4,2
35+
36+
//# abstract --account immshared(4,2) --ptb-inputs 100 @A
37+
//> 0: SplitCoins(Gas, [Input(0)]);
38+
//> 1: TransferObjects([Result(0)], Input(1));
39+
40+
//# view-object 6,0
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
source: external-crates/move/crates/move-transactional-test-runner/src/framework.rs
3+
---
4+
processed 7 tasks
5+
6+
init:
7+
A: object(0,0)
8+
9+
task 1, line 8:
10+
//# publish-dependencies --paths crates/iota-adapter-transactional-tests/data/account_abstraction/simple_abstract_account.move
11+
Output for 'crates/iota-adapter-transactional-tests/data/account_abstraction/simple_abstract_account.move':
12+
created: object(2,0)
13+
mutated: object(0,1)
14+
gas summary: computation_cost: 1000000, computation_cost_burned: 1000000, storage_cost: 7584800, storage_rebate: 0, non_refundable_storage_fee: 0
15+
16+
task 2, lines 10-30:
17+
//# publish --sender A --dependencies simple_abstract_account
18+
created: object(3,0), object(3,1)
19+
mutated: object(0,0)
20+
gas summary: computation_cost: 1000000, computation_cost_burned: 1000000, storage_cost: 11126400, storage_rebate: 0, non_refundable_storage_fee: 0
21+
22+
task 3, line 32:
23+
//# init-abstract-account --sender A --package-metadata object(3,1) --inputs "authenticate" "authenticate_with_event" --create-function simple_abstract_account::abstract_account::create --account-type simple_abstract_account::abstract_account::AbstractAccount
24+
created: object(4,0), object(4,1), object(4,2)
25+
mutated: object(0,0)
26+
gas summary: computation_cost: 1000000, computation_cost_burned: 1000000, storage_cost: 6710800, storage_rebate: 980400, non_refundable_storage_fee: 0
27+
28+
task 4, line 34:
29+
//# view-object 4,2
30+
Owner: Shared( 3 )
31+
Version: 3
32+
Contents: simple_abstract_account::abstract_account::AbstractAccount {
33+
id: iota::object::UID {
34+
id: iota::object::ID {
35+
bytes: fake(4,2),
36+
},
37+
},
38+
}
39+
40+
task 5, lines 36-38:
41+
//# abstract --account immshared(4,2) --ptb-inputs 100 @A
42+
events: Event { package_id: test, transaction_module: Identifier("authenticate"), sender: fake(4,2), type_: StructTag { address: test, module: Identifier("authenticate"), name: Identifier("AuthenticationSuccessEvent"), type_params: [] }, contents: [38, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 32, 65, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 105, 111, 110, 32, 115, 117, 99, 99, 101, 101, 100, 101, 100, 46] }
43+
created: object(6,0)
44+
mutated: object(4,0)
45+
unchanged_shared: object(4,2)
46+
gas summary: computation_cost: 1000000, computation_cost_burned: 1000000, storage_cost: 1960800, storage_rebate: 980400, non_refundable_storage_fee: 0
47+
48+
task 6, line 40:
49+
//# view-object 6,0
50+
Owner: Account Address ( A )
51+
Version: 4
52+
Contents: iota::coin::Coin<iota::iota::IOTA> {
53+
id: iota::object::UID {
54+
id: iota::object::ID {
55+
bytes: fake(6,0),
56+
},
57+
},
58+
balance: iota::balance::Balance<iota::iota::IOTA> {
59+
value: 100u64,
60+
},
61+
}

0 commit comments

Comments
 (0)