xek-sdk
Version:
SDK for katana blockchain
28 lines (23 loc) • 1.11 kB
JavaScript
;
const assert = require ('assert');
const ultis = require ('../src/utils/utils');
describe ('Utilities test', function () {
describe ('Test function isAddress()', function () {
it ('should return true if address is correct', function () {
assert.equal (ultis.isAddress ('E4E7C88BEB93B6A2C70B1D8DFC9493D9D8A55424'), true, "Address is invalid");
});
it ('should return false if address length is invalid', () => {
const address = 'E4E7C88BEB93B6A2C70B1D8DFC9493D9D8A55424AAA';
assert.notEqual (address.length, 40, 'Address length is not 40');
assert.equal (ultis.isAddress (address), false, 'Address length must be equal 40');
});
it ('should return false if address is not hex string', () => {
assert.equal (ultis.isAddress ('E4E7C88BEB93B6A2C70B1D8DFC9493D9D8A5542G'), false, 'Address must be hex string');
});
});
describe ('Test function isBlockHeight()', () => {
it ('block height must be number', () => {
assert.equal (ultis.isBlockHeight ('123123'), true, 'Block height must a number');
});
});
});