import '../setup' ; import { newInMemoryDB } from '@pigi/core-db' ; import { SimpleServer , SimpleClient , DefaultSignatureProvider , } from '@pigi/core-utils' ; import { UnipigTransitioner , Address , SignedTransaction , SignedStateReceipt , UNI_TOKEN_TYPE , PIGI_TOKEN_TYPE , EMPTY_AGGREGATOR_SIGNATURE , NON_EXISTENT_SLOT_INDEX , StateReceipt , RollupClient , } from '../../src' ; import { AGGREGATOR_ADDRESS , DummyRollupStateSolver } from '../helpers' ; /***********
 * HELPERS *
 ***********/ const getStateReceipt = ( pubKey ) : StateReceipt => { return { slotIndex : NON_EXISTENT_SLOT_INDEX , stateRoot : 'mocked' , inclusionProof : [ ] , blockNumber : 1 , transitionIndex : 0 , state : { pubkey : pubKey , balances : { [ UNI_TOKEN_TYPE ] : 5 , [ PIGI_TOKEN_TYPE ] : 10 , } , } , } ; } ; const getState = ( pubKey ) : SignedStateReceipt => { return { signature : EMPTY_AGGREGATOR_SIGNATURE , stateReceipt : getStateReceipt ( pubKey ) , } ; } ; const applyTransaction = ( transaction ) => { } ; /*********
 * TESTS *
 *********/ describe ( 'UnipigTransitioner' , async ( ) => { let unipigTransitioner ; let accountAddress ; let aggregator ; let ovm ; let rollupClient ; const timeout = 20000 ; beforeEach ( async ( ) => { ovm = new DummyRollupStateSolver ( ) ; rollupClient = new RollupClient ( newInMemoryDB ( ) , AGGREGATOR_ADDRESS ) ; unipigTransitioner = new UnipigTransitioner ( newInMemoryDB ( ) , ovm , rollupClient , new DefaultSignatureProvider ( ) , AGGREGATOR_ADDRESS ) ; accountAddress = await unipigTransitioner . getAddress ( ) ; aggregator = new SimpleServer ( { getState , } , 'localhost' , 3000 ) ; await aggregator . listen ( ) ; rollupClient . connect ( new SimpleClient ( 'http://127.0.0.1:3000' ) ) ; } ) ; afterEach ( async ( ) => { await aggregator . close ( ) ; } ) ; describe ( 'getState()' , ( ) => { it ( 'should return an empty balance after initialized' , async ( ) => { const result = await unipigTransitioner . getState ( accountAddress ) ; result . should . deep . equal ( getStateReceipt ( accountAddress ) ) ; } ) . timeout ( timeout ) ; } ) ; } ) ;