11import * as assert from 'assert' ;
22
3- import { extractAddressBufferFromPayGoAttestationProof } from '../../src/paygo' ;
3+ import { parsePayGoAttestation } from '../../src/paygo' ;
44import { generatePayGoAttestationProof } from '../../src/testutil' ;
55
66const addressFromPubKeyBase58 = 'bitgoAddressToExtract' ;
@@ -12,31 +12,35 @@ describe('extractAddressBufferFromPayGoAttestationProof', () => {
1212 '00000000-0000-0000-0000-000000000000' ,
1313 bufferAddressPubKeyB58
1414 ) ;
15- const addressFromProof = extractAddressBufferFromPayGoAttestationProof ( paygoAttestationProof ) ;
16- assert . deepStrictEqual ( Buffer . compare ( addressFromProof , bufferAddressPubKeyB58 ) , 0 ) ;
15+ const { entropy, address, uuid } = parsePayGoAttestation ( paygoAttestationProof ) ;
16+ assert . deepStrictEqual ( Buffer . compare ( address , bufferAddressPubKeyB58 ) , 0 ) ;
17+ assert . deepStrictEqual ( uuid . toString ( ) , '00000000-0000-0000-0000-000000000000' ) ;
18+ assert . deepStrictEqual ( entropy . length , 64 ) ;
1719 } ) ;
1820
1921 it ( 'should extract the paygo address paygo attestation proof given a non nilUUID' , ( ) => {
2022 const paygoAttestationProof = generatePayGoAttestationProof (
2123 '12345678-1234-4567-6890-231928472123' ,
2224 bufferAddressPubKeyB58
2325 ) ;
24- const addressFromProof = extractAddressBufferFromPayGoAttestationProof ( paygoAttestationProof ) ;
25- assert . deepStrictEqual ( Buffer . compare ( addressFromProof , bufferAddressPubKeyB58 ) , 0 ) ;
26+ const { entropy, address, uuid } = parsePayGoAttestation ( paygoAttestationProof ) ;
27+ assert . deepStrictEqual ( Buffer . compare ( address , bufferAddressPubKeyB58 ) , 0 ) ;
28+ assert . deepStrictEqual ( uuid . toString ( ) , '12345678-1234-4567-6890-231928472123' ) ;
29+ assert . deepStrictEqual ( entropy . length , 64 ) ;
2630 } ) ;
2731
2832 it ( 'should not extract the correct address given a uuid of wrong format' , ( ) => {
2933 const paygoAttestationProof = generatePayGoAttestationProof (
3034 '000000000000000-000000-0000000-000000-0000000000000000' ,
3135 bufferAddressPubKeyB58
3236 ) ;
33- const addressFromProof = extractAddressBufferFromPayGoAttestationProof ( paygoAttestationProof ) ;
34- assert . notDeepStrictEqual ( Buffer . compare ( addressFromProof , bufferAddressPubKeyB58 ) , 0 ) ;
37+ const { address } = parsePayGoAttestation ( paygoAttestationProof ) ;
38+ assert . notDeepStrictEqual ( Buffer . compare ( address , bufferAddressPubKeyB58 ) , 0 ) ;
3539 } ) ;
3640
3741 it ( 'should throw an error if the paygo attestation proof is too short' , ( ) => {
3842 assert . throws (
39- ( ) => extractAddressBufferFromPayGoAttestationProof ( Buffer . from ( 'shortproof-shrug' ) ) ,
43+ ( ) => parsePayGoAttestation ( Buffer . from ( 'shortproof-shrug' ) ) ,
4044 'PayGo attestation proof is too short to contain a valid address.'
4145 ) ;
4246 } ) ;
0 commit comments