@@ -278,7 +278,7 @@ contract('[PlasmaMVP] Transactions', async (accounts) => {
278
278
let secondOutput = [ txPos [ 0 ] , txPos [ 1 ] , 1 , 0 ] ;
279
279
await instance . startTransactionExit ( secondOutput , toHex ( txBytes ) , toHex ( proof ) ,
280
280
toHex ( confirmSignatures ) , 0 , { from : authority , value : minExitBond } ) ;
281
-
281
+
282
282
// operator will challenge with second output
283
283
let err ;
284
284
[ err ] = await catchError ( instance . challengeFeeMismatch ( secondOutput , txPos2 , toHex ( txBytes2 ) , proof2 ) ) ;
@@ -738,4 +738,60 @@ contract('[PlasmaMVP] Transactions', async (accounts) => {
738
738
exit = await instance . txExits . call ( position ) ;
739
739
assert . equal ( exit [ 4 ] . toNumber ( ) , 1 , "exit has been challenged or finalized" ) ;
740
740
} ) ;
741
+
742
+ it ( "Does finalize two transaction exits if given enough gas" , async ( ) => {
743
+ depositNonce = ( await instance . depositNonce . call ( ) ) . toNumber ( ) ;
744
+ await instance . deposit ( authority , { from : authority , value : amount } ) ;
745
+
746
+ // deposit is the first input. authority sends entire deposit to accounts[1]
747
+ let txList2 = Array ( 17 ) . fill ( 0 ) ;
748
+ txList2 [ 3 ] = depositNonce ; txList2 [ 12 ] = accounts [ 1 ] ; txList2 [ 13 ] = amount ;
749
+ let txHash2 = web3 . sha3 ( RLP . encode ( txList2 ) . toString ( 'hex' ) , { encoding : 'hex' } ) ;
750
+
751
+ let sigs2 = [ toHex ( await web3 . eth . sign ( authority , txHash2 ) ) , toHex ( Buffer . alloc ( 65 ) . toString ( 'hex' ) ) ] ;
752
+
753
+ txBytes2 = [ txList2 , sigs2 ] ;
754
+ txBytes2 = RLP . encode ( txBytes2 ) . toString ( 'hex' ) ;
755
+
756
+ // submit the block
757
+ let merkleHash2 = sha256String ( txBytes2 ) ;
758
+ let merkleRoot2 , proof2 ;
759
+ [ merkleRoot2 , proof2 ] = generateMerkleRootAndProof ( [ merkleHash2 ] , 0 ) ;
760
+ let blockNum2 = ( await instance . lastCommittedBlock . call ( ) ) . toNumber ( ) + 1 ;
761
+ await instance . submitBlock ( [ toHex ( merkleRoot2 ) ] , [ 1 ] , [ 0 ] , blockNum2 , { from : authority } ) ;
762
+
763
+ // construct the confirm signature
764
+ let confirmHash2 = sha256String ( merkleHash2 + merkleRoot2 . slice ( 2 ) ) ;
765
+ confirmSignatures2 = await web3 . eth . sign ( authority , confirmHash2 ) ;
766
+
767
+ txPos2 = [ blockNum2 , 0 , 0 ] ;
768
+
769
+ // Start txn exit on both utxos
770
+ await instance . startTransactionExit ( txPos ,
771
+ toHex ( txBytes ) , toHex ( proof ) , toHex ( confirmSignatures ) , 0 ,
772
+ { from : accounts [ 1 ] , value : minExitBond } ) ;
773
+
774
+ await instance . startTransactionExit ( txPos2 ,
775
+ toHex ( txBytes2 ) , toHex ( proof2 ) , toHex ( confirmSignatures2 ) , 0 ,
776
+ { from : accounts [ 1 ] , value : minExitBond } ) ;
777
+
778
+ fastForward ( one_week + 1000 ) ;
779
+
780
+ // Provide enough gas for both txns to be finalized
781
+ await instance . finalizeTransactionExits ( { gas : 200000 } ) ;
782
+
783
+ // The both utxo should have been exited correctly
784
+ let balance = ( await instance . balanceOf . call ( accounts [ 1 ] ) ) . toNumber ( ) ;
785
+ assert . equal ( balance , 2 * ( amount + minExitBond ) ) ;
786
+
787
+ // Verify that txn1 has been exited
788
+ let position = 1000000 * txPos [ 0 ] ;
789
+ let exit = await instance . txExits . call ( position ) ;
790
+ assert . equal ( exit [ 4 ] . toNumber ( ) , 3 , "exit's state not set to finalized" ) ;
791
+
792
+ // Verify that txn2 has been exited
793
+ position = 1000000 * txPos2 [ 0 ] ;
794
+ exit = await instance . txExits . call ( position ) ;
795
+ assert . equal ( exit [ 4 ] . toNumber ( ) , 3 , "exit's state not set to finalized" ) ;
796
+ } ) ;
741
797
} ) ;
0 commit comments