Skip to content

Commit

Permalink
Merge pull request #730 from tynes/document-bech32-tests
Browse files Browse the repository at this point in the history
test: document bech32 test vectors
  • Loading branch information
braydonf committed Apr 5, 2019
2 parents 392b383 + 9a56851 commit f57bd51
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/bech32-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
const assert = require('./util/assert');
const Address = require('../lib/primitives/address');

// see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
// for test vectors, they include both the valid and invalid addresses

const validAddresses = [
[
'BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4',
Expand Down Expand Up @@ -81,16 +84,27 @@ const validAddresses = [
];

const invalidAddresses = [
// invalid hrp
'tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty',
// invalid checksum
'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5',
// invalid witness version
'BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2',
// invalid program length
'bc1rw5uspcuh',
// invalid program length
'bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d'
+ '6qejxtdg4y5r3zarvary0c5xw7kw5rljs90',
// invalid program length for witness version 0
'BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P',
// mixed case
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7',
// zero padding of more than 4 bits
'tb1pw508d6qejxtdg4y5r3zarqfsj6c3',
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv'
// non zero padding in 8 to 5 conversion
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv',
// empty data section
'bc1gmk9yu'
];

function createProgram(version, program) {
Expand Down

0 comments on commit f57bd51

Please sign in to comment.