Skip to content

Commit

Permalink
Fix sig tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Feb 28, 2024
1 parent ef3c37f commit b18a317
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 18 additions & 0 deletions packages/ethernaut-signer/test/tasks/active.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ describe('active', function () {
let activeSigner
const terminal = new Terminal()

const demoSig = {
address: '0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f',
pk: '0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97',
}

before('add test signers', async function () {
const signers = storage.readSigners()
if (!('test__3' in signers)) signers.test__3 = demoSig
signers.activeSigner = 'test__3'
storage.storeSigners(signers)
})

after('remove test signers', async function () {
const signers = storage.readSigners()
if ('test__3' in signers) delete signers.test__3
storage.storeSigners(signers)
})

before('get the active signer', async function () {
activeSigner = storage.readSigners().activeSigner
})
Expand Down
14 changes: 5 additions & 9 deletions packages/ethernaut-signer/test/tasks/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe('add', function () {

const removeTestSigners = function () {
const signers = storage.readSigners()
if ('test__1' in signers) delete signers.test__1
if ('test__2' in signers) delete signers.test__1
if ('test__7' in signers) delete signers.test__7
if ('test__8' in signers) delete signers.test__8
storage.storeSigners(signers)
}

Expand All @@ -22,7 +22,7 @@ describe('add', function () {

describe('when generating a random pk', function () {
before('generate', async function () {
await terminal.run('npx hardhat sig add test__1 --pk random')
await terminal.run('npx hardhat sig add test__8 --pk random')
})

it('generates the signer', async function () {
Expand All @@ -32,16 +32,12 @@ describe('add', function () {

describe('when all params are specified', function () {
before('run add', async function () {
await terminal.run(`npx hardhat sig add test__1 --pk ${demoSig.pk}`)
await terminal.run(`npx hardhat sig add test__7 --pk ${demoSig.pk}`)
})

it('adds the signer', async function () {
const signers = storage.readSigners()
assert.deepEqual(
signers.test__1,
{ address: demoSig.address, pk: demoSig.pk },
terminal.output,
)
assert.deepEqual(signers.test__7, demoSig, terminal.output)
})
})
})

0 comments on commit b18a317

Please sign in to comment.