Skip to content

Commit

Permalink
feat: bump js-native version
Browse files Browse the repository at this point in the history
  • Loading branch information
fpelliccioni committed Dec 2, 2024
1 parent 4be5c5a commit fdcf7eb
Show file tree
Hide file tree
Showing 5 changed files with 4,073 additions and 22 deletions.
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@knuth/bch",
"version": "2.4.0",
"version": "2.5.0",
"description": "Bitcoin Cash development platform for Javascript and Typescript applications",
"main": "src/kth.js",
"scripts": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"homepage": "https://github.com/k-nuth/js-api#readme",
"dependencies": {
"bluebird": "^3.7.2",
"@knuth/bch-native": "^1.4.0",
"@knuth/bch-native": "^1.6.0",
"memoizee": "^0.4.14"
},
"devDependencies": {
Expand Down
11 changes: 6 additions & 5 deletions test/node.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions test/wallet/paymentAddress.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

const paymentAddress = require('../../src/wallet/paymentAddress');

test('EmptyAddressShouldFail', () => {
it('should fail when address is empty', () => {
const result = paymentAddress.fromString('');
expect(result.ok).toBe(false);
});

test('WhitespaceAddressShouldFail', () => {
it('should fail when address is whitespace', () => {
const result = paymentAddress.fromString(' ');
expect(result.ok).toBe(false);
});

test('InvalidAddressShouldFail', () => {
it('should fail when address is invalid', () => {
const result = paymentAddress.fromString('abcd');
expect(result.ok).toBe(false);
});

test('MainnetCashAddrAddressOK', () => {
it('should handle mainnet cashaddr address correctly', () => {
const isVal = paymentAddress.isValid('bitcoincash:qrcuqadqrzp2uztjl9wn5sthepkg22majyxw4gmv6p');
expect(isVal).toBe(true);

Expand All @@ -32,7 +32,7 @@ test('MainnetCashAddrAddressOK', () => {
expect(addr.encodedLegacy()).toBe('1P3GQYtcWgZHrrJhUa4ctoQ3QoCU2F65nz');
});

test('MainnetCashAddrNoPrefixAddressOK', () => {
it('should handle mainnet cashaddr address without prefix correctly', () => {
const isVal = paymentAddress.isValid('qrcuqadqrzp2uztjl9wn5sthepkg22majyxw4gmv6p');
expect(isVal).toBe(true);

Expand All @@ -45,7 +45,7 @@ test('MainnetCashAddrNoPrefixAddressOK', () => {
expect(addr.encodedLegacy()).toBe('1P3GQYtcWgZHrrJhUa4ctoQ3QoCU2F65nz');
});

test('MainnetLegacyAddressOK', () => {
it('should handle mainnet legacy address correctly', () => {
const isVal = paymentAddress.isValid('1P3GQYtcWgZHrrJhUa4ctoQ3QoCU2F65nz');
expect(isVal).toBe(true);

Expand All @@ -57,3 +57,15 @@ test('MainnetLegacyAddressOK', () => {
expect(addr.encodedCashTokens()).toBe('bitcoincash:zrcuqadqrzp2uztjl9wn5sthepkg22majypyxk429j');
expect(addr.encodedLegacy()).toBe('1P3GQYtcWgZHrrJhUa4ctoQ3QoCU2F65nz');
});

it('should handle 32-byte CashAddr correctly for mainnet', () => {
const isVal = paymentAddress.isValid('bitcoincash:pvstqkm54dtvnpyqxt5m5n7sjsn4enrlxc526xyxlnjkaycdzfeu69reyzmqx');
expect(isVal).toBe(true);

const result = paymentAddress.fromString('bitcoincash:pvstqkm54dtvnpyqxt5m5n7sjsn4enrlxc526xyxlnjkaycdzfeu69reyzmqx');
expect(result.ok).toBe(true);
const addr = result.obj;
expect(addr.encodedCashAddr()).toBe('bitcoincash:pvstqkm54dtvnpyqxt5m5n7sjsn4enrlxc526xyxlnjkaycdzfeu69reyzmqx');
expect(addr.encodedCashTokens()).toBe('bitcoincash:rvstqkm54dtvnpyqxt5m5n7sjsn4enrlxc526xyxlnjkaycdzfeu6hs99m6ed');
expect(addr.encodedLegacy()).toBe('34frpCV2v6wtzig9xx4Z9XJ6s4jU3zqwR7');// In fact a 32-byte address is not representable in legacy encoding.
});
Loading

0 comments on commit fdcf7eb

Please sign in to comment.