@@ -26,6 +26,7 @@ pub struct TestContext {
26
26
native_token : Address ,
27
27
token_admin : Address ,
28
28
nid : String ,
29
+ upgrade_authority : Address ,
29
30
}
30
31
31
32
impl TestContext {
@@ -38,6 +39,7 @@ impl TestContext {
38
39
relayer : Address :: generate ( & env) ,
39
40
native_token : env. register_stellar_asset_contract ( token_admin. clone ( ) ) ,
40
41
nid : String :: from_str ( & env, "icon" ) ,
42
+ upgrade_authority : Address :: generate ( & env) ,
41
43
env,
42
44
token_admin,
43
45
}
@@ -50,6 +52,7 @@ impl TestContext {
50
52
relayer : self . relayer . clone ( ) ,
51
53
native_token : self . native_token . clone ( ) ,
52
54
xcall_address : self . xcall . clone ( ) ,
55
+ upgrade_authority : self . upgrade_authority . clone ( ) ,
53
56
} ) ;
54
57
}
55
58
@@ -66,6 +69,7 @@ fn get_dummy_initialize_msg(env: &Env) -> InitializeMsg {
66
69
relayer : Address :: generate ( & env) ,
67
70
native_token : env. register_stellar_asset_contract ( Address :: generate ( & env) ) ,
68
71
xcall_address : Address :: generate ( & env) ,
72
+ upgrade_authority : Address :: generate ( & env) ,
69
73
}
70
74
}
71
75
@@ -143,6 +147,34 @@ fn test_set_admin_fail() {
143
147
)
144
148
}
145
149
150
+ #[ test]
151
+ fn test_set_upgrade_authority ( ) {
152
+ let ctx = TestContext :: default ( ) ;
153
+ let client = CentralizedConnectionClient :: new ( & ctx. env , & ctx. contract ) ;
154
+ ctx. init_context ( & client) ;
155
+
156
+ let new_upgrade_authority = Address :: generate ( & ctx. env ) ;
157
+ client. set_upgrade_authority ( & new_upgrade_authority) ;
158
+
159
+ assert_eq ! (
160
+ ctx. env. auths( ) ,
161
+ std:: vec![ (
162
+ ctx. upgrade_authority. clone( ) ,
163
+ AuthorizedInvocation {
164
+ function: AuthorizedFunction :: Contract ( (
165
+ ctx. contract. clone( ) ,
166
+ Symbol :: new( & ctx. env, "set_upgrade_authority" ) ,
167
+ ( & new_upgrade_authority, ) . into_val( & ctx. env)
168
+ ) ) ,
169
+ sub_invocations: std:: vec![ ]
170
+ }
171
+ ) ]
172
+ ) ;
173
+
174
+ let autorhity = client. get_upgrade_authority ( ) ;
175
+ assert_eq ! ( autorhity, new_upgrade_authority) ;
176
+ }
177
+
146
178
#[ test]
147
179
fn test_set_fee ( ) {
148
180
let ctx = TestContext :: default ( ) ;
0 commit comments