-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 changed file
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const Web3 = require('web3') | ||
const web3 = new Web3(Web3.givenProvider || 'http://localhost:8555') | ||
|
||
const { sign, verifyIdentity } = require('../../common.js') | ||
|
||
const IdentityRegistry = artifacts.require('./IdentityRegistry.sol') | ||
const ERC725 = artifacts.require('./examples/Resolvers/ERC725/ERC725RegistryResolver.sol') | ||
|
||
const instances = {} | ||
|
||
contract('Testing ERC725 Resolver', function (accounts) { | ||
const users = [ | ||
{ | ||
address: accounts[1], | ||
private: '0x6bf410ff825d07346c110c5836b33ec76e7d1ee051283937392180b732aa3aff' | ||
}, | ||
{ | ||
address: accounts[2], | ||
private: '0xccc3c84f02b038a5d60d93977ab11eb57005f368b5f62dad29486edeb4566954' | ||
} | ||
] | ||
|
||
it('contracts deployed', async () => { | ||
instances.IdentityRegistry = await IdentityRegistry.new() | ||
instances.ERC725 = await ERC725.new(instances.IdentityRegistry.address) | ||
}) | ||
|
||
describe('Mint Snowflake', async () => { | ||
it('Identity minted', async function () { | ||
const user = users[0] | ||
const otherGuy = users[1] | ||
|
||
await instances.IdentityRegistry.mintIdentity( | ||
user.address, user.address, [instances.ERC725.address], { from: user.address } | ||
) | ||
|
||
await instances.IdentityRegistry.mintIdentity( | ||
otherGuy.address, otherGuy.address, [instances.ERC725.address], { from: otherGuy.address } | ||
) | ||
|
||
user.identity = web3.utils.toBN(1) | ||
otherGuy.identity = web3.utils.toBN(2) | ||
|
||
await verifyIdentity(user.identity, instances.IdentityRegistry, { | ||
recoveryAddress: user.address, | ||
associatedAddresses: [user.address], | ||
providers: [user.address], | ||
resolvers: [instances.ERC725.address] | ||
}) | ||
}) | ||
}) | ||
|
||
describe('All 725 logic', async () => { | ||
const user = users[0] | ||
const otherGuy = users[1] | ||
let claimAddress; | ||
|
||
it('725 mint', async function () { | ||
await instances.ERC725.create725({ from: user.address }) | ||
}) | ||
|
||
it('725 mint FAIL', async function () { | ||
await instances.ERC725.create725({ from: user.address }) | ||
.then(() => assert.fail('able to mint again', 'transaction should fail')) | ||
.catch(error => assert.include( | ||
error.message, 'You already have a 725', 'wrong rejection reason' | ||
)) | ||
}) | ||
|
||
it('725 get', async function () { | ||
claimAddress = await instances.ERC725.get725(1, { from: user.address }) | ||
}) | ||
|
||
it('725 remove', async function () { | ||
await instances.ERC725.remove725({ from: user.address }) | ||
}) | ||
|
||
it('725 claim', async function () { | ||
const success = await instances.ERC725.claim725.call(claimAddress, { from: user.address }) | ||
assert.equal(success, true) | ||
await instances.ERC725.claim725(claimAddress, { from: user.address }) | ||
}) | ||
|
||
it('725 claim FAIL', async function () { | ||
await instances.ERC725.claim725(claimAddress, { from: user.address }) | ||
.then(() => assert.fail('able to mint again', 'transaction should fail')) | ||
.catch(error => assert.include( | ||
error.message, 'You already have a 725', 'wrong rejection reason' | ||
)) | ||
}) | ||
|
||
it('725 claim FAIL 2', async function () { | ||
await instances.ERC725.create725({ from: otherGuy.address }) | ||
claimAddress = await instances.ERC725.get725(2, { from: user.address }) | ||
|
||
await instances.ERC725.remove725({ from: user.address }) | ||
|
||
const success = await instances.ERC725.claim725.call(claimAddress, { from: user.address }) | ||
assert.equal(success, false) | ||
}) | ||
}) | ||
|
||
}) |