mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
merge xaddress tests into main test file
This commit is contained in:
@@ -268,13 +268,18 @@ describe('RippleAPI', function () {
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('isValidAddress', function () {
|
||||
it('returns true for valid address', function () {
|
||||
assert(this.api.isValidAddress('rLczgQHxPhWtjkaQqn3Q6UM8AbRbbRvs5K'));
|
||||
assert(this.api.isValidAddress(addresses.ACCOUNT_X));
|
||||
assert(this.api.isValidAddress(addresses.ACCOUNT_T));
|
||||
})
|
||||
|
||||
it('returns false for invalid address', function () {
|
||||
assert(!this.api.isValidAddress('foobar'));
|
||||
assert(!this.api.isValidAddress(addresses.ACCOUNT_X.slice(0, -1)));
|
||||
assert(!this.api.isValidAddress(addresses.ACCOUNT_T.slice(1)));
|
||||
})
|
||||
})
|
||||
|
||||
@@ -307,7 +312,7 @@ describe('RippleAPI', function () {
|
||||
}, /^Error: Non-base58 character$/)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('deriveAddress', function () {
|
||||
it('returns address for public key', function () {
|
||||
var address = this.api.deriveAddress('035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06');
|
||||
@@ -315,6 +320,21 @@ describe('RippleAPI', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('deriveXAddress', function () {
|
||||
it('returns address for public key', function () {
|
||||
assert.equal(RippleAPI.deriveXAddress({
|
||||
publicKey: '035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06',
|
||||
tag: false,
|
||||
test: false
|
||||
}), 'XVZVpQj8YSVpNyiwXYSqvQoQqgBttTxAZwMcuJd4xteQHyt');
|
||||
assert.equal(RippleAPI.deriveXAddress({
|
||||
publicKey: '035332FBA71D705BD5D97014A833BE2BBB25BEFCD3506198E14AFEA241B98C2D06',
|
||||
tag: false,
|
||||
test: true
|
||||
}), 'TVVrSWtmQQssgVcmoMBcFQZKKf56QscyWLKnUyiuZW8ALU4');
|
||||
})
|
||||
})
|
||||
|
||||
describe('pagination', function () {
|
||||
|
||||
describe('hasNextPage', function () {
|
||||
@@ -3440,7 +3460,6 @@ describe('RippleAPI', function () {
|
||||
_.partial(checkResult, responses.getTrustlines.all, 'getTrustlines'));
|
||||
});
|
||||
|
||||
// @deprecated See corresponding test in `x-address-api-test.js`
|
||||
it('generateAddress', function () {
|
||||
function random() {
|
||||
return _.fill(Array(16), 0);
|
||||
@@ -3458,6 +3477,24 @@ describe('RippleAPI', function () {
|
||||
}, this.api.errors.UnexpectedError);
|
||||
});
|
||||
|
||||
it('generateXAddress', function () {
|
||||
function random() {
|
||||
return _.fill(Array(16), 0);
|
||||
}
|
||||
assert.deepEqual(this.api.generateXAddress({ entropy: random() }),
|
||||
responses.generateXAddress);
|
||||
});
|
||||
|
||||
it('generateXAddress invalid', function () {
|
||||
assert.throws(() => {
|
||||
function random() {
|
||||
return _.fill(Array(1), 0);
|
||||
}
|
||||
this.api.generateXAddress({ entropy: random() });
|
||||
}, this.api.errors.UnexpectedError);
|
||||
});
|
||||
|
||||
|
||||
it('getSettings', function () {
|
||||
return this.api.getSettings(address).then(
|
||||
_.partial(checkResult, responses.getSettings, 'getSettings'));
|
||||
|
||||
Reference in New Issue
Block a user