Skip to content

Commit

Permalink
bumping truffle + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor committed Dec 10, 2020
1 parent 1e4bb43 commit 262e755
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 63 deletions.
2 changes: 1 addition & 1 deletion contracts/templates/TemplateStoreManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract TemplateStoreManager is OwnableUpgradeable {
);

OwnableUpgradeable.__Ownable_init();
//transferOwnership(_owner);
transferOwnership(_owner);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@
"solidity-coverage": "^0.7.9",
"solium": "^1.2.5",
"solium-plugin-security": "^0.1.1",
"truffle": "^5.1.36",
"truffle-contract": "~4.0.31",
"truffle-hdwallet-provider": "~1.0.17",
"truffle": "^5.1.56",
"@truffle/contract": "~4.3.1",
"@truffle/hdwallet-provider": "~1.2.0",
"truffle-typings": "^1.0.8",
"ts-node": "^9.0.0",
"typescript": "^4.0.5",
Expand Down
6 changes: 4 additions & 2 deletions scripts/deploy/truffle-wrapper/deploy/setupContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ async function approveTemplate({
roles,
templateAddress
} = {}) {
if (await TemplateStoreManagerInstance.isOwner({ from: roles.deployer })) {
const contractOwner = await TemplateStoreManagerInstance.owner()
if (contractOwner == roles.deployer) {
await TemplateStoreManagerInstance.approveTemplate(
templateAddress,
{ from: roles.deployer }
Expand All @@ -31,7 +32,8 @@ async function transferOwnership({
)
}

if (await ContractInstance.isOwner({ from: roles.deployer })) {
const contractOwner = await ContractInstance.owner()
if (contractOwner == roles.deployer) {
await ContractInstance.transferOwnership(
roles.ownerWallet,
{ from: roles.deployer }
Expand Down
3 changes: 2 additions & 1 deletion test/unit/Dispenser/setMaxAmount.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ contract('Dispenser', (accounts) => {
dispenser.setMaxAmount(10, { from: someone }),
'revert'
)
assert.equal(false, await dispenser.isOwner({ from: someone }))
const contractOwner = await dispenser.owner()
assert.notEqual(someone, contractOwner)
})
})
})
3 changes: 2 additions & 1 deletion test/unit/Dispenser/setMaxMintAmount.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ contract('Dispenser', (accounts) => {
dispenser.setMaxMintAmount(1000, { from: someone }),
'revert'
)
assert.equal(false, await dispenser.isOwner({ from: someone }))
const contractOwner = await dispenser.owner()
assert.notEqual(someone, contractOwner)
})
})
})
3 changes: 2 additions & 1 deletion test/unit/Dispenser/setMinPeriod.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ contract('Dispenser', (accounts) => {
dispenser.setMinPeriod(10, { from: someone }),
'revert'
)
assert.equal(false, await dispenser.isOwner({ from: someone }))
const contractOwner = await dispenser.owner()
assert.notEqual(someone, contractOwner)
})
})
})
6 changes: 3 additions & 3 deletions test/unit/HashLists/add.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract('HashLists', (accounts) => {
describe('add', () => {
it('should add a new value to list', async () => {
const newAccountHash = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newAccountHash,
{
from: owner
Expand All @@ -38,7 +38,7 @@ contract('HashLists', (accounts) => {

it('should fail if value already exists', async () => {
const newAccountHash = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newAccountHash,
{
from: owner
Expand All @@ -47,7 +47,7 @@ contract('HashLists', (accounts) => {

// assert
await assert.isRejected(
hashList.add(
hashList.methods["add(bytes32)"](
newAccountHash,
{
from: owner
Expand Down
2 changes: 1 addition & 1 deletion test/unit/HashLists/has.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract('HashLists', (accounts) => {
describe('has', () => {
it('should return true if value exists', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand Down
2 changes: 1 addition & 1 deletion test/unit/HashLists/ownership.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract('HashList', (accounts) => {
hashList = await HashLists.new()
await hashList.initialize(owner, { from: owner })
const newAccountHash = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newAccountHash,
{
from: owner
Expand Down
4 changes: 2 additions & 2 deletions test/unit/HashLists/remove.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract('HashList', (accounts) => {
it('should remove value from list', async () => {
const newAccountHash = await hashList.hash(accounts[1])
const listId = await hashList.hash(owner)
await hashList.add(
await hashList.methods["add(bytes32)"](
newAccountHash,
{
from: owner
Expand All @@ -50,7 +50,7 @@ contract('HashList', (accounts) => {

it('should fail to remove if value does not exist', async () => {
const newAccountHash = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newAccountHash,
{
from: owner
Expand Down
8 changes: 4 additions & 4 deletions test/unit/HashLists/update.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract('HashLists', (accounts) => {
describe('update', () => {
it('should fail if value does not exist', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand All @@ -45,7 +45,7 @@ contract('HashLists', (accounts) => {

it('should fail if old value equals new value', async () => {
const oldValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
oldValue,
{
from: owner
Expand All @@ -68,7 +68,7 @@ contract('HashLists', (accounts) => {
const newValue = await hashList.hash(accounts[2])
const listId = await hashList.hash(owner)

await hashList.add(
await hashList.methods["add(bytes32)"](
oldValue,
{
from: owner
Expand Down Expand Up @@ -96,7 +96,7 @@ contract('HashLists', (accounts) => {
it('should fail in case of invalid list owner', async () => {
const oldValue = await hashList.hash(accounts[1])
const invalidOwner = accounts[5]
await hashList.add(
await hashList.methods["add(bytes32)"](
oldValue,
{
from: owner
Expand Down
10 changes: 5 additions & 5 deletions test/unit/HashLists/utils.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract('HashLists', (accounts) => {
describe('get', () => {
it('should return value by index', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand All @@ -46,7 +46,7 @@ contract('HashLists', (accounts) => {
describe('all', () => {
it('should return all list values', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand All @@ -63,7 +63,7 @@ contract('HashLists', (accounts) => {
describe('indexOf', () => {
it('should return index of value in a list', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand Down Expand Up @@ -94,7 +94,7 @@ contract('HashLists', (accounts) => {

it('should return true if indexed in case of add single element', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand Down Expand Up @@ -159,7 +159,7 @@ contract('HashLists', (accounts) => {
describe('size', () => {
it('should return size', async () => {
const newValue = await hashList.hash(accounts[1])
await hashList.add(
await hashList.methods["add(bytes32)"](
newValue,
{
from: owner
Expand Down
10 changes: 5 additions & 5 deletions test/unit/conditions/WhitelistingCondition.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ contract('Whitelisting Condition', (accounts) => {
const someone = accounts[9]
const listOwner = createRole
const value = await hashList.hash(someone)
await hashList.add(
await hashList.methods["add(bytes32)"](
value,
{
from: listOwner
Expand Down Expand Up @@ -167,7 +167,7 @@ contract('Whitelisting Condition', (accounts) => {
const someone = accounts[9]

const value = await hashList.hash(someone)
await hashList.add(
await hashList.methods["add(bytes32)"](
value,
{
from: owner
Expand Down Expand Up @@ -214,7 +214,7 @@ contract('Whitelisting Condition', (accounts) => {
const someone = accounts[9]

const value = await hashList.hash(someone)
await hashList.add(
await hashList.methods["add(bytes32)"](
value,
{
from: owner
Expand Down Expand Up @@ -258,7 +258,7 @@ contract('Whitelisting Condition', (accounts) => {

const value = await hashList.hash(someone)
const listOwner = createRole
await hashList.add(
await hashList.methods["add(bytes32)"](
value,
{
from: listOwner
Expand Down Expand Up @@ -311,7 +311,7 @@ contract('Whitelisting Condition', (accounts) => {
const someone = accounts[9]

const value = await hashList.hash(someone)
await hashList.add(
await hashList.methods["add(bytes32)"](
value,
{
from: owner
Expand Down

0 comments on commit 262e755

Please sign in to comment.