@@ -131,20 +131,16 @@ func TestGetLatestTokenAccountRecordsForOwner(t *testing.T) {
131131 require .NoError (t , err )
132132 assert .Empty (t , actual )
133133
134- authority1 := newRandomTestAccount ( t )
134+ authority1 := owner
135135 authority2 := newRandomTestAccount (t )
136136 authority3 := newRandomTestAccount (t )
137137 authority4 := newRandomTestAccount (t )
138- authority5 := newRandomTestAccount (t )
139- authority6 := newRandomTestAccount (t )
140- authority7 := newRandomTestAccount (t )
141138
142139 for _ , authorityAndType := range []struct {
143140 account * Account
144141 accountType commonpb.AccountType
145142 }{
146- {authority1 , commonpb .AccountType_BUCKET_1_KIN },
147- {authority2 , commonpb .AccountType_BUCKET_10_KIN },
143+ {authority1 , commonpb .AccountType_PRIMARY },
148144 } {
149145 timelockAccounts , err := authorityAndType .account .GetTimelockAccounts (vmAccount , coreMintAccount )
150146 require .NoError (t , err )
@@ -162,14 +158,11 @@ func TestGetLatestTokenAccountRecordsForOwner(t *testing.T) {
162158 require .NoError (t , data .CreateAccountInfo (ctx , accountInfoRecord ))
163159 }
164160
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 ,
171164 } {
172- timelockAccounts , err := authorityAndRelationship . account .GetTimelockAccounts (vmAccount , coreMintAccount )
165+ timelockAccounts , err := authority .GetTimelockAccounts (vmAccount , coreMintAccount )
173166 require .NoError (t , err )
174167
175168 timelockRecord := timelockAccounts .ToDBRecord ()
@@ -180,101 +173,56 @@ func TestGetLatestTokenAccountRecordsForOwner(t *testing.T) {
180173 AuthorityAccount : timelockRecord .VaultOwner ,
181174 TokenAccount : timelockRecord .VaultAddress ,
182175 MintAccount : coreMintAccount .PublicKey ().ToBase58 (),
183- AccountType : commonpb .AccountType_RELATIONSHIP ,
184- RelationshipTo : & authorityAndRelationship . domain ,
176+ AccountType : commonpb .AccountType_POOL ,
177+ Index : uint64 ( i ) ,
185178 }
186179 require .NoError (t , data .CreateAccountInfo (ctx , accountInfoRecord ))
187180 }
188181
189- swapAta , err := owner .ToAssociatedTokenAccount (authority5 )
182+ swapAta , err := owner .ToAssociatedTokenAccount (authority4 )
190183 require .NoError (t , err )
191184 swapAccountInfoRecord := & account.Record {
192185 OwnerAccount : owner .PublicKey ().ToBase58 (),
193- AuthorityAccount : authority5 .PublicKey ().ToBase58 (),
186+ AuthorityAccount : authority4 .PublicKey ().ToBase58 (),
194187 TokenAccount : swapAta .PublicKey ().ToBase58 (),
195188 MintAccount : swapMintAccount .PublicKey ().ToBase58 (),
196189 AccountType : commonpb .AccountType_SWAP ,
197190 }
198191 require .NoError (t , data .CreateAccountInfo (ctx , swapAccountInfoRecord ))
199192
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-
221193 actual , err = GetLatestTokenAccountRecordsForOwner (ctx , data , owner )
222194 require .NoError (t , err )
223- require .Len (t , actual , 5 )
195+ require .Len (t , actual , 3 )
224196
225- records , ok := actual [commonpb .AccountType_BUCKET_1_KIN ]
197+ records , ok := actual [commonpb .AccountType_PRIMARY ]
226198 require .True (t , ok )
227199 require .Len (t , records , 1 )
228200 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 )
230202 assert .Equal (t , records [0 ].Timelock .VaultOwner , authority1 .PublicKey ().ToBase58 ())
231203 assert .Equal (t , records [0 ].General .TokenAccount , records [0 ].Timelock .VaultAddress )
232204
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-
257205 records , ok = actual [commonpb .AccountType_SWAP ]
258206 require .True (t , ok )
259207 require .Len (t , records , 1 )
260208 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 ())
262210 assert .Equal (t , records [0 ].General .TokenAccount , swapAta .PublicKey ().ToBase58 ())
263211 assert .Equal (t , records [0 ].General .AccountType , commonpb .AccountType_SWAP )
264212
265213 records , ok = actual [commonpb .AccountType_POOL ]
266214 require .True (t , ok )
267215 require .Len (t , records , 2 )
268216
269- assert .Equal (t , records [0 ].General .AuthorityAccount , authority6 .PublicKey ().ToBase58 ())
217+ assert .Equal (t , records [0 ].General .AuthorityAccount , authority2 .PublicKey ().ToBase58 ())
270218 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 ())
272220 assert .Equal (t , records [0 ].General .TokenAccount , records [0 ].Timelock .VaultAddress )
273221 assert .EqualValues (t , records [0 ].General .Index , 0 )
274222
275- assert .Equal (t , records [1 ].General .AuthorityAccount , authority7 .PublicKey ().ToBase58 ())
223+ assert .Equal (t , records [1 ].General .AuthorityAccount , authority3 .PublicKey ().ToBase58 ())
276224 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 ())
278226 assert .Equal (t , records [1 ].General .TokenAccount , records [1 ].Timelock .VaultAddress )
279227 assert .EqualValues (t , records [1 ].General .Index , 1 )
280228}
0 commit comments