@@ -131,20 +131,16 @@ func TestGetLatestTokenAccountRecordsForOwner(t *testing.T) {
131
131
require .NoError (t , err )
132
132
assert .Empty (t , actual )
133
133
134
- authority1 := newRandomTestAccount ( t )
134
+ authority1 := owner
135
135
authority2 := newRandomTestAccount (t )
136
136
authority3 := newRandomTestAccount (t )
137
137
authority4 := newRandomTestAccount (t )
138
- authority5 := newRandomTestAccount (t )
139
- authority6 := newRandomTestAccount (t )
140
- authority7 := newRandomTestAccount (t )
141
138
142
139
for _ , authorityAndType := range []struct {
143
140
account * Account
144
141
accountType commonpb.AccountType
145
142
}{
146
- {authority1 , commonpb .AccountType_BUCKET_1_KIN },
147
- {authority2 , commonpb .AccountType_BUCKET_10_KIN },
143
+ {authority1 , commonpb .AccountType_PRIMARY },
148
144
} {
149
145
timelockAccounts , err := authorityAndType .account .GetTimelockAccounts (vmAccount , coreMintAccount )
150
146
require .NoError (t , err )
@@ -162,14 +158,11 @@ func TestGetLatestTokenAccountRecordsForOwner(t *testing.T) {
162
158
require .NoError (t , data .CreateAccountInfo (ctx , accountInfoRecord ))
163
159
}
164
160
165
- for _ , authorityAndRelationship := range []struct {
166
- account * Account
167
- domain string
168
- }{
169
- {authority3 , "app1.com" },
170
- {authority4 , "app2.com" },
161
+ for i , authority := range []* Account {
162
+ authority2 ,
163
+ authority3 ,
171
164
} {
172
- timelockAccounts , err := authorityAndRelationship . account .GetTimelockAccounts (vmAccount , coreMintAccount )
165
+ timelockAccounts , err := authority .GetTimelockAccounts (vmAccount , coreMintAccount )
173
166
require .NoError (t , err )
174
167
175
168
timelockRecord := timelockAccounts .ToDBRecord ()
@@ -180,101 +173,56 @@ func TestGetLatestTokenAccountRecordsForOwner(t *testing.T) {
180
173
AuthorityAccount : timelockRecord .VaultOwner ,
181
174
TokenAccount : timelockRecord .VaultAddress ,
182
175
MintAccount : coreMintAccount .PublicKey ().ToBase58 (),
183
- AccountType : commonpb .AccountType_RELATIONSHIP ,
184
- RelationshipTo : & authorityAndRelationship . domain ,
176
+ AccountType : commonpb .AccountType_POOL ,
177
+ Index : uint64 ( i ) ,
185
178
}
186
179
require .NoError (t , data .CreateAccountInfo (ctx , accountInfoRecord ))
187
180
}
188
181
189
- swapAta , err := owner .ToAssociatedTokenAccount (authority5 )
182
+ swapAta , err := owner .ToAssociatedTokenAccount (authority4 )
190
183
require .NoError (t , err )
191
184
swapAccountInfoRecord := & account.Record {
192
185
OwnerAccount : owner .PublicKey ().ToBase58 (),
193
- AuthorityAccount : authority5 .PublicKey ().ToBase58 (),
186
+ AuthorityAccount : authority4 .PublicKey ().ToBase58 (),
194
187
TokenAccount : swapAta .PublicKey ().ToBase58 (),
195
188
MintAccount : swapMintAccount .PublicKey ().ToBase58 (),
196
189
AccountType : commonpb .AccountType_SWAP ,
197
190
}
198
191
require .NoError (t , data .CreateAccountInfo (ctx , swapAccountInfoRecord ))
199
192
200
- for i , authority := range []* Account {
201
- authority6 ,
202
- authority7 ,
203
- } {
204
- timelockAccounts , err := authority .GetTimelockAccounts (vmAccount , coreMintAccount )
205
- require .NoError (t , err )
206
-
207
- timelockRecord := timelockAccounts .ToDBRecord ()
208
- require .NoError (t , data .SaveTimelock (ctx , timelockRecord ))
209
-
210
- accountInfoRecord := & account.Record {
211
- OwnerAccount : owner .PublicKey ().ToBase58 (),
212
- AuthorityAccount : timelockRecord .VaultOwner ,
213
- TokenAccount : timelockRecord .VaultAddress ,
214
- MintAccount : coreMintAccount .PublicKey ().ToBase58 (),
215
- AccountType : commonpb .AccountType_POOL ,
216
- Index : uint64 (i ),
217
- }
218
- require .NoError (t , data .CreateAccountInfo (ctx , accountInfoRecord ))
219
- }
220
-
221
193
actual , err = GetLatestTokenAccountRecordsForOwner (ctx , data , owner )
222
194
require .NoError (t , err )
223
- require .Len (t , actual , 5 )
195
+ require .Len (t , actual , 3 )
224
196
225
- records , ok := actual [commonpb .AccountType_BUCKET_1_KIN ]
197
+ records , ok := actual [commonpb .AccountType_PRIMARY ]
226
198
require .True (t , ok )
227
199
require .Len (t , records , 1 )
228
200
assert .Equal (t , records [0 ].General .AuthorityAccount , authority1 .PublicKey ().ToBase58 ())
229
- assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_BUCKET_1_KIN )
201
+ assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_PRIMARY )
230
202
assert .Equal (t , records [0 ].Timelock .VaultOwner , authority1 .PublicKey ().ToBase58 ())
231
203
assert .Equal (t , records [0 ].General .TokenAccount , records [0 ].Timelock .VaultAddress )
232
204
233
- records , ok = actual [commonpb .AccountType_BUCKET_10_KIN ]
234
- require .True (t , ok )
235
- require .Len (t , records , 1 )
236
- assert .Equal (t , records [0 ].General .AuthorityAccount , authority2 .PublicKey ().ToBase58 ())
237
- assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_BUCKET_10_KIN )
238
- assert .Equal (t , records [0 ].Timelock .VaultOwner , authority2 .PublicKey ().ToBase58 ())
239
- assert .Equal (t , records [0 ].General .TokenAccount , records [0 ].Timelock .VaultAddress )
240
-
241
- records , ok = actual [commonpb .AccountType_RELATIONSHIP ]
242
- require .True (t , ok )
243
- require .Len (t , records , 2 )
244
-
245
- assert .Equal (t , records [0 ].General .AuthorityAccount , authority3 .PublicKey ().ToBase58 ())
246
- assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_RELATIONSHIP )
247
- assert .Equal (t , records [0 ].Timelock .VaultOwner , authority3 .PublicKey ().ToBase58 ())
248
- assert .Equal (t , records [0 ].General .TokenAccount , records [0 ].Timelock .VaultAddress )
249
- assert .Equal (t , * records [0 ].General .RelationshipTo , "app1.com" )
250
-
251
- assert .Equal (t , records [1 ].General .AuthorityAccount , authority4 .PublicKey ().ToBase58 ())
252
- assert .Equal (t , records [1 ].General .AccountType , commonpb .AccountType_RELATIONSHIP )
253
- assert .Equal (t , records [1 ].Timelock .VaultOwner , authority4 .PublicKey ().ToBase58 ())
254
- assert .Equal (t , records [1 ].General .TokenAccount , records [1 ].Timelock .VaultAddress )
255
- assert .Equal (t , * records [1 ].General .RelationshipTo , "app2.com" )
256
-
257
205
records , ok = actual [commonpb .AccountType_SWAP ]
258
206
require .True (t , ok )
259
207
require .Len (t , records , 1 )
260
208
assert .Nil (t , records [0 ].Timelock )
261
- assert .Equal (t , records [0 ].General .AuthorityAccount , authority5 .PublicKey ().ToBase58 ())
209
+ assert .Equal (t , records [0 ].General .AuthorityAccount , authority4 .PublicKey ().ToBase58 ())
262
210
assert .Equal (t , records [0 ].General .TokenAccount , swapAta .PublicKey ().ToBase58 ())
263
211
assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_SWAP )
264
212
265
213
records , ok = actual [commonpb .AccountType_POOL ]
266
214
require .True (t , ok )
267
215
require .Len (t , records , 2 )
268
216
269
- assert .Equal (t , records [0 ].General .AuthorityAccount , authority6 .PublicKey ().ToBase58 ())
217
+ assert .Equal (t , records [0 ].General .AuthorityAccount , authority2 .PublicKey ().ToBase58 ())
270
218
assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_POOL )
271
- assert .Equal (t , records [0 ].Timelock .VaultOwner , authority6 .PublicKey ().ToBase58 ())
219
+ assert .Equal (t , records [0 ].Timelock .VaultOwner , authority2 .PublicKey ().ToBase58 ())
272
220
assert .Equal (t , records [0 ].General .TokenAccount , records [0 ].Timelock .VaultAddress )
273
221
assert .EqualValues (t , records [0 ].General .Index , 0 )
274
222
275
- assert .Equal (t , records [1 ].General .AuthorityAccount , authority7 .PublicKey ().ToBase58 ())
223
+ assert .Equal (t , records [1 ].General .AuthorityAccount , authority3 .PublicKey ().ToBase58 ())
276
224
assert .Equal (t , records [1 ].General .AccountType , commonpb .AccountType_POOL )
277
- assert .Equal (t , records [1 ].Timelock .VaultOwner , authority7 .PublicKey ().ToBase58 ())
225
+ assert .Equal (t , records [1 ].Timelock .VaultOwner , authority3 .PublicKey ().ToBase58 ())
278
226
assert .Equal (t , records [1 ].General .TokenAccount , records [1 ].Timelock .VaultAddress )
279
227
assert .EqualValues (t , records [1 ].General .Index , 1 )
280
228
}
0 commit comments