@@ -14,16 +14,14 @@ import {
1414} from '../../../src/bitgo' ;
1515import { Input as TestUtilInput } from '../../../src/testutil' ;
1616import { AcidTest , InputScriptType , SignStage } from '../../../src/testutil/psbt' ;
17- import { getNetworkList , getNetworkName , isMainnet , networks } from '../../../src' ;
17+ import { getNetworkName } from '../../../src' ;
1818import {
1919 parsePsbtMusig2Nonces ,
2020 parsePsbtMusig2PartialSigs ,
2121 parsePsbtMusig2Participants ,
2222} from '../../../src/bitgo/Musig2' ;
2323import { getFixture } from '../../fixture.util' ;
2424
25- const signs = [ 'unsigned' , 'halfsigned' , 'fullsigned' ] as const ;
26-
2725function getSigValidArray ( scriptType : InputScriptType , signStage : SignStage ) : Triple < boolean > {
2826 if ( scriptType === 'p2shP2pk' || signStage === 'unsigned' ) {
2927 return [ false , false , false ] ;
@@ -83,7 +81,7 @@ function runPsbt(acidTest: AcidTest) {
8381 const coin = getNetworkName ( acidTest . network ) ;
8482 const signatureCount = signCount ( acidTest . signStage ) ;
8583
86- describe ( `psbt build, sign and verify for ${ coin } ${ acidTest . signStage } ` , function ( ) {
84+ describe ( `psbt suite for ${ acidTest . name } ` , function ( ) {
8785 let psbt : UtxoPsbt ;
8886
8987 before ( function ( ) {
@@ -94,20 +92,6 @@ function runPsbt(acidTest: AcidTest) {
9492 assert . deepStrictEqual ( psbt . toBuffer ( ) , createPsbtFromBuffer ( psbt . toBuffer ( ) , acidTest . network ) . toBuffer ( ) ) ;
9593 } ) ;
9694
97- it ( `getSignatureValidationArray with globalXpub ${ coin } ${ acidTest . signStage } ` , function ( ) {
98- psbt . data . inputs . forEach ( ( input , inputIndex ) => {
99- const isP2shP2pk = acidTest . inputs [ inputIndex ] . scriptType === 'p2shP2pk' ;
100- const expectedSigValid = getSigValidArray ( acidTest . inputs [ inputIndex ] . scriptType , acidTest . signStage ) ;
101- psbt . getSignatureValidationArray ( inputIndex , { rootNodes : acidTest . rootWalletKeys . triple } ) . forEach ( ( sv , i ) => {
102- if ( isP2shP2pk && acidTest . signStage !== 'unsigned' && i === 0 ) {
103- assert . strictEqual ( sv , true ) ;
104- } else {
105- assert . strictEqual ( sv , expectedSigValid [ i ] ) ;
106- }
107- } ) ;
108- } ) ;
109- } ) ;
110-
11195 it ( 'matches fixture' , async function ( ) {
11296 let finalizedPsbt : UtxoPsbt | undefined ;
11397 let extractedTransaction : Buffer | undefined ;
@@ -130,7 +114,7 @@ function runPsbt(acidTest: AcidTest) {
130114 assert . deepStrictEqual ( fixture , await getFixture ( `${ __dirname } /../fixtures/psbt/${ filename } ` , fixture ) ) ;
131115 } ) ;
132116
133- it ( `getSignatureValidationArray with rootNodes ${ coin } ${ acidTest . signStage } ` , function ( ) {
117+ it ( `getSignatureValidationArray` , function ( ) {
134118 psbt . data . inputs . forEach ( ( input , inputIndex ) => {
135119 const isP2shP2pk = acidTest . inputs [ inputIndex ] . scriptType === 'p2shP2pk' ;
136120 const expectedSigValid = getSigValidArray ( acidTest . inputs [ inputIndex ] . scriptType , acidTest . signStage ) ;
@@ -144,7 +128,7 @@ function runPsbt(acidTest: AcidTest) {
144128 } ) ;
145129 } ) ;
146130
147- it ( `getSignatureValidationArrayPsbt ${ coin } ${ acidTest . signStage } ` , function ( ) {
131+ it ( `getSignatureValidationArrayPsbt` , function ( ) {
148132 const sigValidations = getSignatureValidationArrayPsbt ( psbt , acidTest . rootWalletKeys ) ;
149133 psbt . data . inputs . forEach ( ( input , inputIndex ) => {
150134 const expectedSigValid = getSigValidArray ( acidTest . inputs [ inputIndex ] . scriptType , acidTest . signStage ) ;
@@ -154,7 +138,7 @@ function runPsbt(acidTest: AcidTest) {
154138 } ) ;
155139 } ) ;
156140
157- it ( `psbt signature counts ${ coin } ${ acidTest . signStage } ` , function ( ) {
141+ it ( `psbt signature counts` , function ( ) {
158142 const counts = getStrictSignatureCounts ( psbt ) ;
159143 const countsFromInputs = getStrictSignatureCounts ( psbt . data . inputs ) ;
160144
@@ -186,11 +170,6 @@ function runPsbt(acidTest: AcidTest) {
186170 } ) ;
187171}
188172
189- signs . forEach ( ( sign ) => {
190- getNetworkList ( )
191- . filter ( ( v ) => isMainnet ( v ) && v !== networks . bitcoinsv )
192- . forEach ( ( network ) => {
193- runPsbt ( AcidTest . withDefaults ( network , sign , 'psbt' ) ) ;
194- runPsbt ( AcidTest . withDefaults ( network , sign , 'psbt-lite' ) ) ;
195- } ) ;
173+ AcidTest . suite ( ) . forEach ( ( acidTest ) => {
174+ runPsbt ( acidTest ) ;
196175} ) ;
0 commit comments