mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-07-21 20:55:42 +00:00
Initial rebrand: @polkadot -> @pezkuwi (14 packages)
- Package namespace: @polkadot/* -> @pezkuwi/* - Repository: polkadot-js/common -> pezkuwichain/pezkuwi-common - Author: Pezkuwi Team <team@pezkuwichain.io> Core packages: - @pezkuwi/util (utilities) - @pezkuwi/util-crypto (crypto primitives) - @pezkuwi/keyring (account management) - @pezkuwi/networks (chain metadata) - @pezkuwi/hw-ledger (Ledger hardware wallet) - @pezkuwi/x-* (10 polyfill packages) Total: 14 packages Upstream: polkadot-js/common v14.0.1
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { checkAddress } from './index.js';
|
||||
|
||||
describe('checkAddress', (): void => {
|
||||
it('returns [true, null] for Kusama', (): void => {
|
||||
expect(
|
||||
checkAddress('FJaco77EJ99VtBmVFibuBJR3x5Qq9KQrgQJvWjqScCcCCae', 2)
|
||||
).toEqual([true, null]);
|
||||
});
|
||||
|
||||
it('returns [true, null] for Substrate', (): void => {
|
||||
expect(
|
||||
checkAddress('5EnxxUmEbw8DkENKiYuZ1DwQuMoB2UWEQJZZXrTsxoz7SpgG', 42)
|
||||
).toEqual([true, null]);
|
||||
});
|
||||
|
||||
it('fails when an invalid base58 character is supplied', (): void => {
|
||||
expect(
|
||||
checkAddress('5EnxIUmEbw8DkENKiYuZ1DwQuMoB2UWEQJZZXrTsxoz7SpgG', 2)
|
||||
).toEqual([false, 'Invalid base58 character "I" (0x49) at index 4']);
|
||||
});
|
||||
|
||||
it('fails with invalid prefix when checking Substrate against Kusama prefix', (): void => {
|
||||
expect(
|
||||
checkAddress('5EnxxUmEbw8DkENKiYuZ1DwQuMoB2UWEQJZZXrTsxoz7SpgG', 2)
|
||||
).toEqual([false, 'Prefix mismatch, expected 2, found 42']);
|
||||
});
|
||||
|
||||
it('fails with invalid length when some bytes are missing', (): void => {
|
||||
expect(
|
||||
checkAddress('y9EMHt34JJo4rWLSaxoLGdYXvjgSXEd4zHUnQgfNzwES8b', 42)
|
||||
).toEqual([false, 'Invalid decoded address length']);
|
||||
});
|
||||
|
||||
it('fails with invalid length on checksum mismatch', (): void => {
|
||||
expect(
|
||||
checkAddress('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDwU', 42)
|
||||
).toEqual([false, 'Invalid decoded address checksum']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user