1
1
import * as assert from 'assert' ;
2
2
3
- import { extractAddressBufferFromPayGoAttestationProof } from '../../src/paygo' ;
3
+ import { parsePayGoAttestation } from '../../src/paygo' ;
4
4
import { generatePayGoAttestationProof } from '../../src/testutil' ;
5
5
6
6
const addressFromPubKeyBase58 = 'bitgoAddressToExtract' ;
@@ -12,31 +12,35 @@ describe('extractAddressBufferFromPayGoAttestationProof', () => {
12
12
'00000000-0000-0000-0000-000000000000' ,
13
13
bufferAddressPubKeyB58
14
14
) ;
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 ) ;
17
19
} ) ;
18
20
19
21
it ( 'should extract the paygo address paygo attestation proof given a non nilUUID' , ( ) => {
20
22
const paygoAttestationProof = generatePayGoAttestationProof (
21
23
'12345678-1234-4567-6890-231928472123' ,
22
24
bufferAddressPubKeyB58
23
25
) ;
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 ) ;
26
30
} ) ;
27
31
28
32
it ( 'should not extract the correct address given a uuid of wrong format' , ( ) => {
29
33
const paygoAttestationProof = generatePayGoAttestationProof (
30
34
'000000000000000-000000-0000000-000000-0000000000000000' ,
31
35
bufferAddressPubKeyB58
32
36
) ;
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 ) ;
35
39
} ) ;
36
40
37
41
it ( 'should throw an error if the paygo attestation proof is too short' , ( ) => {
38
42
assert . throws (
39
- ( ) => extractAddressBufferFromPayGoAttestationProof ( Buffer . from ( 'shortproof-shrug' ) ) ,
43
+ ( ) => parsePayGoAttestation ( Buffer . from ( 'shortproof-shrug' ) ) ,
40
44
'PayGo attestation proof is too short to contain a valid address.'
41
45
) ;
42
46
} ) ;
0 commit comments