@@ -8,6 +8,7 @@ import * as testData from '../fixtures';
88import { chainName , txVersion , genesisHash , specVersion } from '../resources' ;
99import * as sinon from 'sinon' ;
1010import { Wallet } from '@bitgo/sdk-core' ;
11+ import assert = require( 'assert' ) ;
1112
1213describe ( 'DOT:' , function ( ) {
1314 let bitgo : TestBitGoAPI ;
@@ -664,12 +665,69 @@ describe('DOT:', function () {
664665 walletPassphrase : 'fakeWalletPassphrase' ,
665666 } ;
666667
668+ const txPrebuild = {
669+ txHex :
670+ '0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300' ,
671+ } ;
672+
667673 await basecoin
668- . verifyTransaction ( { txParams } )
674+ . verifyTransaction ( { txPrebuild , txParams } )
669675 . should . be . rejectedWith (
670676 `tdot doesn't support sending to more than 1 destination address within a single transaction. Try again, using only a single recipient.`
671677 ) ;
672678 } ) ;
679+
680+ it ( 'should reject a txPrebuild with more than invalid amount' , async function ( ) {
681+ const wallet = new Wallet ( bitgo , basecoin , { } ) ;
682+ const txParams = {
683+ recipients : [ { amount : '20000000000' , address : '5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD' } ] ,
684+ wallet : wallet ,
685+ walletPassphrase : 'fakeWalletPassphrase' ,
686+ } ;
687+ const txPrebuild = {
688+ txHex :
689+ '0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300' ,
690+ } ;
691+
692+ await basecoin
693+ . verifyTransaction ( { txPrebuild, txParams } )
694+ . should . be . rejectedWith ( `Recipient amount 20000000000 does not match transaction amount 2000000000000` ) ;
695+ } ) ;
696+
697+ it ( 'should reject a txPrebuild with more than invalid recipient' , async function ( ) {
698+ const wallet = new Wallet ( bitgo , basecoin , { } ) ;
699+ const txParams = {
700+ recipients : [ { amount : '2000000000000' , address : '5CZh773vKGwKFCUjGc31AwXCbf7TPkavduk2XoujJMjbBD' } ] ,
701+ wallet : wallet ,
702+ walletPassphrase : 'fakeWalletPassphrase' ,
703+ } ;
704+ const txPrebuild = {
705+ txHex :
706+ '0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300' ,
707+ } ;
708+
709+ await basecoin
710+ . verifyTransaction ( { txPrebuild, txParams } )
711+ . should . be . rejectedWith (
712+ `Recipient address 5CZh773vKGwKFCUjGc31AwXCbf7TPkavduk2XoujJMjbBD does not match transaction destination address 5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD`
713+ ) ;
714+ } ) ;
715+
716+ it ( 'should accept a txPrebuild with more than valid recipient and amount' , async function ( ) {
717+ const wallet = new Wallet ( bitgo , basecoin , { } ) ;
718+ const txParams = {
719+ recipients : [ { amount : '2000000000000' , address : '5CZh773vKGwKFCYUjGc31AwXCbf7TPkavdeuk2XoujJMjbBD' } ] ,
720+ wallet : wallet ,
721+ walletPassphrase : 'fakeWalletPassphrase' ,
722+ } ;
723+ const txPrebuild = {
724+ txHex :
725+ '0xa80a0300161b969b6b53ef81225feea3882284c778cd4a406d23215fcf492e83f75d42960b00204aa9d101eb600400000065900f001000000067f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9a7b7420ee3e4fe2b88da0fc42b30897e18d56d8b56a1934211d9de730cf96de300' ,
726+ } ;
727+
728+ const result = await basecoin . verifyTransaction ( { txPrebuild, txParams } ) ;
729+ assert . strictEqual ( result , true ) ;
730+ } ) ;
673731 } ) ;
674732
675733 describe ( 'isWalletAddress' , ( ) => {
0 commit comments