11import assert from 'assert' ;
22
33import { BitGoAPI } from '@bitgo/sdk-api' ;
4- import { TransactionType } from '@bitgo/sdk-core' ;
4+ import { ITransactionRecipient , TransactionType , Wallet } from '@bitgo/sdk-core' ;
55import { TestBitGo , TestBitGoAPI } from '@bitgo/sdk-test' ;
66
77import { getCantonBuilderFactory } from '../helper' ;
88import {
99 CANTON_RECEIVE_ADDRESS ,
1010 GenerateTopologyResponse ,
1111 TransferAcceptRawTransaction ,
12+ TransferRawTxn ,
1213 TransferRejectRawTransaction ,
14+ TxParams ,
1315 WalletInitRawTransaction ,
1416} from '../resources' ;
1517import { Tcanton } from '../../src' ;
1618
1719describe ( 'Canton integration tests' , function ( ) {
1820 let bitgo : TestBitGoAPI ;
1921 let basecoin : Tcanton ;
22+ let newTxPrebuild : ( ) => { txHex : string ; txInfo : Record < string , unknown > } ;
23+ let newTxParams : ( ) => { recipients : ITransactionRecipient [ ] } ;
24+ let wallet : Wallet ;
25+ const txPrebuild = {
26+ txHex : TransferRawTxn ,
27+ txInfo : { } ,
28+ } ;
29+ const txParams = {
30+ recipients : [
31+ {
32+ address : TxParams . RECIPIENT_ADDRESS ,
33+ amount : TxParams . AMOUNT ,
34+ } ,
35+ ] ,
36+ } ;
2037 before ( ( ) => {
2138 bitgo = TestBitGo . decorate ( BitGoAPI , { env : 'mock' } ) ;
2239 bitgo . safeRegister ( 'tcanton' , Tcanton . createInstance ) ;
2340 basecoin = bitgo . coin ( 'tcanton' ) as Tcanton ;
41+ newTxPrebuild = ( ) => {
42+ return structuredClone ( txPrebuild ) ;
43+ } ;
44+ newTxParams = ( ) => {
45+ return structuredClone ( txParams ) ;
46+ } ;
47+ wallet = new Wallet ( bitgo , basecoin , { } ) ;
48+ } ) ;
49+
50+ describe ( 'Verify Transaction' , function ( ) {
51+ it ( 'should verify transfer transaction' , async function ( ) {
52+ const txPrebuild = newTxPrebuild ( ) ;
53+ const txParams = newTxParams ( ) ;
54+ const isTxnVerifies = await basecoin . verifyTransaction ( { txPrebuild : txPrebuild , txParams : txParams , wallet } ) ;
55+ isTxnVerifies . should . equal ( true ) ;
56+ } ) ;
2457 } ) ;
2558
2659 describe ( 'Explain raw transaction' , function ( ) {
@@ -41,7 +74,7 @@ describe('Canton integration tests', function () {
4174 assert ( explainTxData ) ;
4275 assert ( explainTxData . id ) ;
4376 assert . equal ( explainTxData . type , TransactionType . TransferAccept ) ;
44- assert . equal ( explainTxData . inputAmount , '5.0000000000 ' ) ;
77+ assert . equal ( explainTxData . inputAmount , '50000000000 ' ) ;
4578 } ) ;
4679
4780 it ( 'should explain raw transfer rejection transaction' , function ( ) {
@@ -50,7 +83,7 @@ describe('Canton integration tests', function () {
5083 const explainTxData = txn . explainTransaction ( ) ;
5184 assert ( explainTxData ) ;
5285 assert . equal ( explainTxData . type , TransactionType . TransferReject ) ;
53- assert . equal ( explainTxData . inputAmount , '5.0000000000 ' ) ;
86+ assert . equal ( explainTxData . inputAmount , '50000000000 ' ) ;
5487 } ) ;
5588 } ) ;
5689
0 commit comments