import Objection from 'objection' ; import { SignedState as WireSignedState } from '@statechannels/wire-format' ; import { utils } from 'ethers' ; import { Store } from '../store' ; import { Channel } from '../../models/channel' ; import { testKnex as knex } from '../../../jest/knex-setup-teardown' ; import { defaultTestWalletConfig } from '../../config' ; let store ; beforeAll ( async ( ) => { store = new Store ( knex , defaultTestWalletConfig ( ) . metricsConfiguration . timingMetrics , defaultTestWalletConfig ( ) . skipEvmValidation , '0' ) ; } ) ; describe ( 'addSignedState' , ( ) => { let tx ; afterEach ( async ( ) => tx . rollback ( ) ) ; beforeEach ( async ( ) => { tx = await Channel . startTransaction ( knex ) ; } ) ; const BOB_SIGNATURE = '0x36a5fd36a1c9a85afdeee3f9471579656eefceb08bc0ff53d194a67d6433c6385cc8c9aa049306fc7cce901f7b3345bccde311cceadc74a40a89a9d74d86d9b91b' ; const channelId = '0x00' ; it ( 'throws when the signer is not a participant' , async ( ) => { const signedState = { appData : '0x' , appDefinition : '0x0000000000000000000000000000000000000000' , isFinal : false , turnNum : 0 , outcome : [ { asset : '0x2222E21c8019b14dA16235319D34b5Dd83E644A9' , allocationItems : [ { destination : '0x2222E21c8019b14dA16235319D34b5Dd83E644A9' , amount : '0x00' } , ] , } , ] , participants : [ ] , channelNonce : 1 , channelId , chainId : utils . hexlify ( defaultTestWalletConfig ( ) . networkConfiguration . chainNetworkID ) , challengeDuration : 9001 , signatures : [ BOB_SIGNATURE ] , } ; await expect ( store . addSignedState ( channelId , signedState , knex as any ) ) . rejects . toThrow ( /is not a participant/ ) ; } ) ; } ) ;