11import { PrivateKey , TokenId } from 'o1js' ;
22import { createActionsList } from './fetch.js' ;
3- import { mockFetchActionsResponse } from './fixtures/fetch-actions-response.js' ;
3+ import { mockFetchActionsResponse as fetchResponseWithTxInfo } from './fixtures/fetch-actions-response-with-transaction-info.js' ;
4+ import { mockFetchActionsResponse as fetchResponseNoTxInfo } from './fixtures/fetch-actions-response-without-transaction-info.js' ;
45import { test , describe } from 'node:test' ;
56import { removeJsonQuotes } from './graphql.js' ;
67import { expect } from 'expect' ;
@@ -123,8 +124,8 @@ expect(actual).toEqual(expected);
123124
124125console . log ( 'regex tests complete 🎉' ) ;
125126
126- describe ( 'Fetch' , async ( t ) => {
127- describe ( '#createActionsList with default params' , async ( t ) => {
127+ describe ( 'Fetch' , ( ) => {
128+ describe ( '#createActionsList with default params' , ( ) => {
128129 const defaultPublicKey = PrivateKey . random ( ) . toPublicKey ( ) . toBase58 ( ) ;
129130 const defaultActionStates = {
130131 fromActionState : undefined ,
@@ -136,96 +137,50 @@ describe('Fetch', async (t) => {
136137 tokenId : TokenId . default . toString ( ) ,
137138 } ;
138139
139- const actionsList = createActionsList (
140- defaultAccountInfo ,
141- mockFetchActionsResponse . data . actions
142- ) ;
143-
144- await test ( 'orders the actions correctly' , async ( ) => {
145- expect ( actionsList ) . toEqual ( [
146- {
147- actions : [
148- [
149- '20374659537065244088703638031937922870146667362923279084491778322749365537089' ,
150- '1' ,
151- ] ,
152- ] ,
153- hash : '10619825168606131449407092474314250900469658818945385329390497057469974757422' ,
154- } ,
155- {
156- actions : [
157- [
158- '20503089751358270987184701275168489753952341816059774976784079526478451099801' ,
159- '1' ,
160- ] ,
161- ] ,
162- hash : '25525130517416993227046681664758665799110129890808721833148757111140891481208' ,
163- } ,
164- {
165- actions : [
166- [
167- '3374074164183544078218789545772953663729921088152354292852793744356608231707' ,
168- '0' ,
169- ] ,
170- ] ,
171- hash : '290963518424616502946790040851348455652296009700336010663574777600482385855' ,
172- } ,
173- {
174- actions : [
175- [
176- '12630758077588166643924428865613845067150916064939816120404808842510620524633' ,
177- '1' ,
178- ] ,
179- ] ,
180- hash : '20673199655841577810393943638910551364027795297920791498278816237738641857371' ,
181- } ,
182- {
183- actions : [
184- [
185- '5643224648393140391519847064914429159616501351124129591669928700148350171602' ,
186- '0' ,
187- ] ,
188- ] ,
189- hash : '5284016523143033193387918577616839424871122381326995145988133445906503263869' ,
190- } ,
191- {
192- actions : [
193- [
194- '15789351988619560045401465240113496854401074115453702466673859303925517061263' ,
195- '0' ,
196- ] ,
197- ] ,
198- hash : '16944163018367910067334012882171366051616125936127175065464614786387687317044' ,
199- } ,
200- {
201- actions : [
202- [
203- '27263309408256888453299195755797013857604561285332380691270111409680109142128' ,
204- '1' ,
205- ] ,
206- ] ,
207- hash : '23662159967366296714544063539035629952291787828104373633198732070740691309118' ,
208- } ,
209- {
210- actions : [
211- [
212- '3378367318331499715304980508337843233019278703665446829424824679144818589558' ,
213- '1' ,
214- ] ,
215- ] ,
216- hash : '1589729766029695153975344283092689798747741638003354620355672853210932754595' ,
217- } ,
218- {
219- actions : [
220- [
221- '17137397755795687855356639427474789131368991089558570411893673365904353943290' ,
222- '1' ,
223- ] ,
224- ] ,
225- hash : '10964420428484427410756859799314206378989718180435238943573393516522086219419' ,
226- } ,
227- ] ) ;
140+ describe ( 'with a payload that is missing transaction info' , ( ) => {
141+ const actionsList = createActionsList (
142+ defaultAccountInfo ,
143+ fetchResponseNoTxInfo . data . actions
144+ ) ;
145+
146+ test ( 'orders the actions correctly' , ( ) => {
147+ const correctActionsHashes = [
148+ '10619825168606131449407092474314250900469658818945385329390497057469974757422' ,
149+ '25525130517416993227046681664758665799110129890808721833148757111140891481208' ,
150+ '290963518424616502946790040851348455652296009700336010663574777600482385855' ,
151+ '20673199655841577810393943638910551364027795297920791498278816237738641857371' ,
152+ '5284016523143033193387918577616839424871122381326995145988133445906503263869' ,
153+ '16944163018367910067334012882171366051616125936127175065464614786387687317044' ,
154+ '23662159967366296714544063539035629952291787828104373633198732070740691309118' ,
155+ '1589729766029695153975344283092689798747741638003354620355672853210932754595' ,
156+ '10964420428484427410756859799314206378989718180435238943573393516522086219419' ,
157+ ] ;
158+ expect ( actionsList . map ( ( { hash } ) => hash ) ) . toEqual (
159+ correctActionsHashes
160+ ) ;
161+ } ) ;
162+ } ) ;
163+
164+ describe ( 'with a payload that includes transaction info' , ( ) => {
165+ const actionsList = createActionsList (
166+ defaultAccountInfo ,
167+ fetchResponseWithTxInfo . data . actions
168+ ) ;
169+
170+ test ( 'orders the actions correctly' , ( ) => {
171+ const correctActionsHashes = [
172+ '23562173419146814432140831830018386191372262558717813981702672868292521523493' ,
173+ '17091049856171838105194364005412166905307014398334933913160405653259432088216' ,
174+ '17232885850087529233459756382038742870248640044940153006158312935267918515979' ,
175+ '12636308717155378495657553296284990333618148856424346334743675423201692801125' ,
176+ '17082487567758469425757467457967473265642001333824907522427890208991758759731' ,
177+ '14226491442770650712364681911870921131508915865197379983185088742764625929348' ,
178+ '13552033292375176242184292341671233419412691991179711376625259275814019808194' ,
179+ ] ;
180+ expect ( actionsList . map ( ( { hash } ) => hash ) ) . toEqual (
181+ correctActionsHashes
182+ ) ;
183+ } ) ;
228184 } ) ;
229185 } ) ;
230186} ) ;
231- `` ;
0 commit comments