-
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.
- Loading branch information
Showing
3 changed files
with
86 additions
and
3 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,76 @@ | ||
import '@nomicfoundation/hardhat-chai-matchers'; | ||
|
||
import {expect} from 'chai'; | ||
import * as deployment from '../utils/deploy'; | ||
import {getAccounts, Account, toGRT} from '../utils/helpers'; | ||
|
||
import {Registry, EntryStructOutput} from '../types/contracts/Registry'; | ||
import {BigNumber} from 'ethers'; | ||
import {setAutoMine} from './helpers'; | ||
|
||
describe('Registry contract', () => { | ||
// Accounts | ||
let deployer: Account; | ||
let other: Account; | ||
|
||
// Contracts | ||
let registry: Registry; | ||
|
||
before(async function () { | ||
[deployer, other] = await getAccounts(); | ||
|
||
setAutoMine(true); | ||
}); | ||
|
||
beforeEach(async function () { | ||
registry = await deployment.deployRegistry(deployer.signer, false); | ||
}); | ||
|
||
describe('constructor', function () { | ||
it('should set the owner to the contract deployer address', async function () { | ||
expect(await registry.owner()).to.eq(deployer.address); | ||
}); | ||
}); | ||
|
||
describe('transferOwnership', function () { | ||
it('should set the owner to the new owner', async function () { | ||
await registry.transferOwnership(other.address); | ||
expect(await registry.owner()).to.eq(other.address); | ||
}); | ||
}); | ||
|
||
describe('insertEntry', function () { | ||
it('should set entry', async function () { | ||
const entryID = BigNumber.from(1); | ||
const entry = { | ||
subscriptions: [ | ||
'0x0000000000000000000000000000000000000001', | ||
'0x0000000000000000000000000000000000000002', | ||
], | ||
metadataHash: | ||
'0x0000000000000000000000000000000000000000000000000000000000000001', | ||
}; | ||
await registry.insertEntry(entryID, entry); | ||
const entry_ = await registry.entries(entryID); | ||
console.log({entry_}); | ||
expect(await registry.entries(entryID)).to.eq(entry); | ||
}); | ||
|
||
// it('should overwrite entry', async function () { | ||
// // TODO | ||
// }); | ||
}); | ||
|
||
// describe('removeEntry', function () { | ||
// it('should remove entry', async function () { | ||
// const entryID = BigNumber.from(1); | ||
// const subscriptions = ["0x0000000000000000000000000000000000000001"]; | ||
// const metadataHash = "0x0000000000000000000000000000000000000000000000000000000000000001"; | ||
// await registry.insertEntry(entryID, {subscriptions, metadataHash}); | ||
// // await registry.removeEntry(entryID); | ||
// const entries = await registry.entries(entryID); | ||
// console.log({ entries }); | ||
// // expect(await registry.entries()).to.eq(subscriptionsOwner1.address); | ||
// }); | ||
// }); | ||
}); |
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