Skip to content

Commit

Permalink
Some tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Nov 15, 2024
1 parent 5b56159 commit 0d279ed
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toUint8Array } from '@xylabs/arraybuffer'

import { Elliptic } from '../Elliptic'
import { Elliptic } from '../Elliptic.ts'

describe('AddressValue', () => {
const valid: [string, string, string][] = [
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('AddressValue', () => {
describe('verify', () => {
it.each(valid)('Verifies a signature', async (message, signature, address) => {
const result = await Elliptic.verify(toUint8Array(message), toUint8Array(signature), toUint8Array(address))
expect(result).toBeTrue()
expect(result).toBeTruthy()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

describe('Node Wallet Test - Commented Out', () => {
it('Stub', () => {
expect(true).toBeTrue()
expect(true).toBe(true)
})
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HDWallet } from '../../HDWallet'
import { generateHDWalletTests } from './HDWallet.spec'
import { HDWallet } from '../../HDWallet.ts'
import { generateHDWalletTests } from './HDWallet.spec.ts'

/**
* @group nodejs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
defaultPath, Mnemonic, SigningKey,
} from 'ethers'

import { HDWallet } from '../../HDWallet'
import { HDWallet } from '../../HDWallet.ts'

/**
* The wallet types that can be tested
Expand Down Expand Up @@ -68,9 +68,9 @@ const snapshotWalletInstances = (walletA: Wallet, walletB: Wallet) => {
const expectWalletsEqual = (sutA: WalletInstance, sutB: Wallet) => {
expect(sutA.address).toEqual(formatHexString(sutB.address))
expect(sutA.privateKey).toEqual(sutB.privateKey)
expect(sutA.private.hex).toEqual(formatHexString(sutB.privateKey))
expect(sutA.private?.hex).toEqual(formatHexString(sutB.privateKey))
expect(sutA.publicKey).toEqual(sutB.publicKey)
expect(sutA.public.hex).toEqual(toUncompressedPublicKey(sutB.publicKey))
expect(sutA.public?.hex).toEqual(toUncompressedPublicKey(sutB.publicKey))
}

/**
Expand Down Expand Up @@ -173,7 +173,7 @@ export const generateHDWalletTests = (title: string, HDWallet: WalletStatic) =>
}

test('HDWallet tests generator is defined', () => {
expect(generateHDWalletTests).toBeFunction()
expect(typeof generateHDWalletTests).toBe('function')
})

test('Same address, two paths', async () => {
Expand Down Expand Up @@ -205,3 +205,9 @@ test('Random Wallet', async () => {
expect(sut.path).toBeDefined()
expect(sut.path).toBe(defaultPath)
})

test('HDWallet can be created from mnemonic', async () => {
const sut = await HDWallet.fromPhrase('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', "m/44'/0'/0'/0/0")
expect(sut).toBeDefined()
console.log('address', sut.privateKey)
})
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('PrivateKey', () => {
const data = toUint8Array(hash)
const wasmSignature = await privateKey.sign(data)
const wasmVerify = await privateKey.verify(data, wasmSignature)
expect(wasmVerify).toBeTrue()
expect(wasmVerify).toBeTruthy()
})
// TODO: Negative verification testing
test('wasm vs js (performance-serial)', async () => {
Expand Down

0 comments on commit 0d279ed

Please sign in to comment.