Skip to content

Commit fcf940c

Browse files
authored
feat(iota-e2e-tests): Provide e2e tests for create_auth_info feature (#8539)
# Description of change Added a number of e2e tests for the `iota-execution/latest/iota-verifier/src/account_auth_verifier.rs`. ## Links to any relevant issues fixes #8414 fixes #8525 ## How the change has been tested - [ ] Basic tests (linting, compilation, formatting, unit/integration tests) - [ ] Patch-specific tests (correctness, functionality coverage) - [x] I have added tests that prove my fix is effective or that my feature works - [ ] I have checked that new and existing unit tests pass locally with my changes
1 parent 2323b06 commit fcf940c

File tree

10 files changed

+839
-0
lines changed

10 files changed

+839
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/*
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "authenticate"
3+
edition = "2024"
4+
5+
[dependencies]
6+
Iota = { local = "../../../../iota-framework/packages/iota-framework" }
7+
8+
[addresses]
9+
authenticate = "0x0"
10+
11+
[dev-dependencies]
12+
13+
[dev-addresses]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module authenticate::object;
5+
6+
use iota::auth_context::AuthContext;
7+
8+
// Object
9+
10+
public struct Object has key, store {
11+
id: iota::object::UID,
12+
}
13+
14+
// PASS
15+
public fun immutable_ref(
16+
_object: &Object,
17+
_auth_ctx: &AuthContext,
18+
_ctx: &TxContext,
19+
) {}
20+
21+
// FAIL
22+
#[allow(lint(share_owned))]
23+
public fun by_value(object: Object, _auth_ctx: &AuthContext, _ctx: &TxContext) {
24+
transfer::public_share_object(object);
25+
}
26+
27+
// FAIL
28+
public fun by_mutable_ref(
29+
_object: &mut Object,
30+
_auth_ctx: &AuthContext,
31+
_ctx: &TxContext,
32+
) {}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module authenticate::option;
5+
6+
use iota::auth_context::AuthContext;
7+
8+
public struct Object has key, store {
9+
id: iota::object::UID,
10+
}
11+
12+
#[allow(unused_field)]
13+
public struct ObjectTemplated<T: key + store> has copy, drop, store {
14+
t: T,
15+
}
16+
17+
#[allow(unused_field)]
18+
public struct NonObjectTemplated<T: copy + drop + store> has copy, drop, store {
19+
t: T,
20+
}
21+
22+
public struct NonObject has copy, drop, store {}
23+
24+
// Option
25+
26+
// PASS
27+
public fun primitive_immutable_reference(
28+
_arg: &Option<u8>,
29+
_auth_ctx: &AuthContext,
30+
_ctx: &TxContext,
31+
) {}
32+
33+
// FAIL
34+
public fun primitive_mutable_reference(
35+
_arg: &mut Option<u8>,
36+
_auth_ctx: &AuthContext,
37+
_ctx: &TxContext,
38+
) {}
39+
40+
// PASS
41+
public fun primitive_by_value(_arg: Option<u8>, _auth_ctx: &AuthContext, _ctx: &TxContext) {}
42+
43+
// FAIL
44+
public fun non_object_immutable_ref(
45+
_arg: &Option<NonObject>,
46+
_auth_ctx: &AuthContext,
47+
_ctx: &TxContext,
48+
) {}
49+
50+
// FAIL
51+
public fun non_object_mutable_ref(
52+
_arg: &mut Option<NonObject>,
53+
_auth_ctx: &AuthContext,
54+
_ctx: &TxContext,
55+
) {}
56+
57+
// FAIL
58+
public fun non_object_by_value(
59+
_arg: Option<NonObject>,
60+
_auth_ctx: &AuthContext,
61+
_ctx: &TxContext,
62+
) {}
63+
64+
// Option and object
65+
66+
// PASS
67+
public fun object_immutable_ref(
68+
_objects: &Option<Object>,
69+
_auth_ctx: &AuthContext,
70+
_ctx: &TxContext,
71+
) {}
72+
73+
// FAIL
74+
public fun object_mutable_ref(
75+
_objects: &mut Option<Object>,
76+
_auth_ctx: &AuthContext,
77+
_ctx: &TxContext,
78+
) {}
79+
80+
// FAIL
81+
#[allow(lint(share_owned))]
82+
public fun object_by_value(objects: Option<Object>, _auth_ctx: &AuthContext, _ctx: &TxContext) {
83+
objects.do!(|object| transfer::public_share_object(object));
84+
}
85+
86+
// Option and template
87+
88+
// error[E06001]: unused value without 'drop'
89+
//public fun template_non_object_by_value<T>(
90+
// _arg: Option<T>,
91+
// _auth_ctx: &AuthContext,
92+
// _ctx: &TxContext,
93+
//) {}
94+
95+
// PASS
96+
public fun template_non_object_immutable_ref<T>(
97+
_arg: &Option<T>,
98+
_auth_ctx: &AuthContext,
99+
_ctx: &TxContext,
100+
) {}
101+
102+
// FAIL
103+
public fun template_non_object_mutable_ref<T>(
104+
_arg: &mut Option<T>,
105+
_auth_ctx: &AuthContext,
106+
_ctx: &TxContext,
107+
) {}
108+
109+
// FAIL
110+
public fun templated_non_object_by_value<T: copy + drop + store>(
111+
_arg: Option<NonObjectTemplated<T>>,
112+
_auth_ctx: &AuthContext,
113+
_ctx: &TxContext,
114+
) {}
115+
116+
// PASS
117+
public fun templated_non_object_immutable_ref<T: copy + drop + store>(
118+
_arg: &Option<NonObjectTemplated<T>>,
119+
_auth_ctx: &AuthContext,
120+
_ctx: &TxContext,
121+
) {}
122+
123+
// FAIL
124+
public fun templated_non_object_mutable_ref<T: copy + drop + store>(
125+
_arg: &mut Option<NonObjectTemplated<T>>,
126+
_auth_ctx: &AuthContext,
127+
_ctx: &TxContext,
128+
) {}
129+
130+
// Option, template and object
131+
132+
// PASS
133+
public fun template_object_immutable_reference<T: key>(
134+
_objects: &Option<T>,
135+
_auth_ctx: &AuthContext,
136+
_ctx: &TxContext,
137+
) {}
138+
139+
// FAIL
140+
public fun template_object_by_value<T: key + store>(
141+
objects: Option<T>,
142+
_auth_ctx: &AuthContext,
143+
_ctx: &TxContext,
144+
) {
145+
objects.do!(|object| transfer::public_share_object(object));
146+
}
147+
148+
// FAIL
149+
public fun template_object_mutable_reference<T: key>(
150+
_objects: &mut Option<T>,
151+
_auth_ctx: &AuthContext,
152+
_ctx: &TxContext,
153+
) {}
154+
155+
// PASS
156+
public fun templated_object_immutable_ref<T: key + store>(
157+
_objects: &Option<ObjectTemplated<T>>,
158+
_auth_ctx: &AuthContext,
159+
_ctx: &TxContext,
160+
) {}
161+
162+
// FAIL
163+
public fun templated_object_by_value<T: key + store>(
164+
objects: Option<ObjectTemplated<T>>,
165+
_auth_ctx: &AuthContext,
166+
_ctx: &TxContext,
167+
) {
168+
objects.do!(|object| {
169+
let ObjectTemplated { t } = object;
170+
transfer::public_share_object(t);
171+
});
172+
}
173+
174+
// FAIL
175+
public fun templated_object_mutable_ref<T: key + store>(
176+
_objects: &mut Option<ObjectTemplated<T>>,
177+
_auth_ctx: &AuthContext,
178+
_ctx: &TxContext,
179+
) {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module authenticate::signature;
5+
6+
use iota::auth_context::AuthContext;
7+
8+
// PASS
9+
public fun minimally_viable_auth_function(_auth_ctx: &AuthContext, _ctx: &TxContext) {}
10+
11+
// FAIL
12+
#[allow(unused_function)]
13+
fun has_to_be_public_auth_function(_auth_ctx: &AuthContext, _ctx: &TxContext) {}
14+
15+
// FAIL
16+
public fun at_least_two_args(_ctx: &TxContext) {}
17+
18+
// FAIL
19+
public fun auth_context_cant_be_value(_auth_ctx: AuthContext, _ctx: &TxContext) {}
20+
21+
// FAIL
22+
public fun auth_context_cant_be_mutable_ref(_auth_ctx: &mut AuthContext, _ctx: &TxContext) {}
23+
24+
// FAIL
25+
public fun tx_context_cant_be_value(_auth_ctx: &AuthContext, _ctx: TxContext) {}
26+
27+
// FAIL
28+
public fun tx_context_cant_be_mutable_ref(_auth_ctx: &AuthContext, _ctx: &mut TxContext) {}
29+
30+
// FAIL
31+
public fun auth_context_isnt_struct(_auth_ctx: u64, _ctx: &TxContext) {}
32+
33+
// FAIL
34+
public fun tx_context_isnt_struct(_auth_ctx: &AuthContext, _ctx: u64) {}
35+
36+
// PASS
37+
public fun arg_value(_val: u8, _auth_ctx: &AuthContext, _ctx: &TxContext) {}
38+
39+
// PASS
40+
public fun arg_mutable_value(mut _val: u8, _auth_ctx: &AuthContext, _ctx: &TxContext) {}
41+
42+
// FAIL
43+
public fun with_signer(_s: signer, _auth_ctx: &AuthContext, _ctx: &TxContext) {}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright (c) 2025 IOTA Stiftung
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module authenticate::template;
5+
6+
use iota::auth_context::AuthContext;
7+
8+
public struct Object has key, store {
9+
id: iota::object::UID,
10+
}
11+
12+
// Template
13+
14+
#[allow(unused_field)]
15+
public struct NonObjectTemplated<T: copy + drop + store> has copy, drop, store {
16+
t: T,
17+
}
18+
19+
// PASS
20+
public fun primitive<T: copy + drop + store>(
21+
_arg: T,
22+
_auth_ctx: &AuthContext,
23+
_ctx: &TxContext,
24+
) {}
25+
26+
// PASS
27+
public fun templated_non_object_immutable_ref<T: copy + drop + store>(
28+
_arg: &NonObjectTemplated<T>,
29+
_auth_ctx: &AuthContext,
30+
_ctx: &TxContext,
31+
) {}
32+
33+
// FAIL
34+
public fun templated_non_object_mutable_ref<T: copy + drop + store>(
35+
_arg: &mut NonObjectTemplated<T>,
36+
_auth_ctx: &AuthContext,
37+
_ctx: &TxContext,
38+
) {}
39+
40+
// FAIL
41+
public fun templated_non_object_by_value<T: copy + drop + store>(
42+
_arg: NonObjectTemplated<T>,
43+
_auth_ctx: &AuthContext,
44+
_ctx: &TxContext,
45+
) {}
46+
47+
// Template and object
48+
49+
// PASS
50+
public fun object_immutable_ref<T: key>(
51+
_object: &T,
52+
_auth_ctx: &AuthContext,
53+
_ctx: &TxContext,
54+
) {}
55+
56+
// FAIL
57+
public fun object_by_value<T: key + store>(
58+
object: T,
59+
_auth_ctx: &AuthContext,
60+
_ctx: &TxContext,
61+
) {
62+
transfer::public_share_object(object);
63+
}
64+
65+
// FAIL
66+
public fun object_mutable_ref<T: key>(
67+
_object: &mut T,
68+
_auth_ctx: &AuthContext,
69+
_ctx: &TxContext,
70+
) {}
71+
72+
#[allow(unused_field)]
73+
public struct ObjectTemplated<T: key + store> has copy, drop, store {
74+
t: T,
75+
}
76+
77+
// PASS
78+
public fun templated_object_immutable_ref<T: key + store>(
79+
_object: &ObjectTemplated<T>,
80+
_auth_ctx: &AuthContext,
81+
_ctx: &TxContext,
82+
) {}
83+
84+
// FAIL
85+
public fun templated_object_by_value<T: key + store>(
86+
object: ObjectTemplated<T>,
87+
_auth_ctx: &AuthContext,
88+
_ctx: &TxContext,
89+
) {
90+
let ObjectTemplated { t } = object;
91+
transfer::public_share_object(t);
92+
}
93+
94+
// FAIL
95+
public fun templated_object_mutable_ref<T: key + store>(
96+
_object: &mut ObjectTemplated<T>,
97+
_auth_ctx: &AuthContext,
98+
_ctx: &TxContext,
99+
) {}

0 commit comments

Comments
 (0)