-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from polkadot-cloud/rb-init-tests
feat: init tests
- Loading branch information
Showing
8 changed files
with
497 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/mocharc.json", | ||
"require": "tsx", | ||
"spec": "test/**/*.spec.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 @polkadot-cloud/polkadot-developer-console authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import assert from 'assert'; | ||
import { u8aToHex, u8aToNumber } from '@polkadot/util'; | ||
import { base58Decode, base58Encode } from '@polkadot/util-crypto'; | ||
|
||
// Test decoding and encoding of an account. Extracts the SS58 Prefix and public key, before | ||
// encoding back to the correct address. | ||
|
||
describe('Encoding ', () => { | ||
it('encoding and decoding should work correctly.', () => { | ||
const encoded = '1hYiMW8KSfUYChzCQSPGXvMSyKVqmyvMXqohjKr3oU5PCXF'; | ||
|
||
const decoded = base58Decode(encoded); | ||
const decodedHex = u8aToHex(decoded); | ||
const ss58 = u8aToNumber(decoded.subarray(0, 1)); | ||
const publicKey = u8aToHex(decoded.subarray(2)); | ||
const encodedKey = base58Encode(decoded); | ||
|
||
assert.equal( | ||
decodedHex, | ||
'0x001eec92559de5be4295be18caa79400d49466b8b06a4c819e766a7b79ad3b846d9476' | ||
); | ||
assert.equal(ss58, '0'); | ||
assert.equal( | ||
publicKey, | ||
'0xec92559de5be4295be18caa79400d49466b8b06a4c819e766a7b79ad3b846d9476' | ||
); | ||
|
||
assert.equal(encodedKey, encoded); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
}, | ||
"include": [ | ||
"src", | ||
"test", | ||
], | ||
"references": [{ "path": "./tsconfig.node.json" }] | ||
} |
Oops, something went wrong.