Skip to content

Commit

Permalink
pull registry#17
Browse files Browse the repository at this point in the history
  • Loading branch information
wjmelements committed Feb 27, 2019
1 parent 12809c9 commit 081e396
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 37 deletions.
68 changes: 34 additions & 34 deletions GasProfile.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"reduceToNewNoRefund": 98247,
"reduceToExistingNoRefund": 83247,
"emptyToExistingNoRefund": 68311,
"emptyToNewNoRefund": 83311,
"reduceApprovalReducingToNew": 109519,
"reduceApprovalReducingToExisting": 94519,
"reduceApprovalEmptyingToNew": 94583,
"reduceApprovalEmptyingToExisting": 79519,
"emptyApprovalReducingToNew": 94519,
"emptyApprovalReducingToExisting": 79583,
"emptyApprovalEmptyingToNew": 79583,
"emptyApprovalEmptyingToExisting": 64583,
"reduceToNewNoRefund": 97895,
"reduceToExistingNoRefund": 82895,
"emptyToExistingNoRefund": 67959,
"emptyToNewNoRefund": 82959,
"reduceApprovalReducingToNew": 109123,
"reduceApprovalReducingToExisting": 94123,
"reduceApprovalEmptyingToNew": 94187,
"reduceApprovalEmptyingToExisting": 79123,
"emptyApprovalReducingToNew": 94123,
"emptyApprovalReducingToExisting": 79187,
"emptyApprovalEmptyingToNew": 79187,
"emptyApprovalEmptyingToExisting": 64187,
"approve50": 61430,
"reduceToBurn": 124969,
"emptyToBurn": 95033,
"burnMicroDollar": 139969,
"reduceToBurnWithChange": 125033,
"emptyToBurnWithChange": 110033,
"reduceToNewWithRefund": 75365,
"reduceToExistingWithRefund": 60365,
"emptyToExistingWithRefund": 52715,
"emptyToNewWithRefund": 60429,
"reduceApprovalReducingToNewWithRefund": 86637,
"reduceApprovalReducingToExistingWithRefund": 71637,
"reduceApprovalEmptyingToNewWithRefund": 71701,
"reduceApprovalEmptyingToExistingWithRefund": 58319,
"emptyApprovalReducingToNewWithRefund": 71637,
"emptyApprovalReducingToExistingWithRefund": 58351,
"emptyApprovalEmptyingToNewWithRefund": 65851,
"emptyApprovalEmptyingToExistingWithRefund": 58351,
"reduceToBurn": 124595,
"emptyToBurn": 94659,
"burnMicroDollar": 139595,
"reduceToBurnWithChange": 124659,
"emptyToBurnWithChange": 109659,
"reduceToNewWithRefund": 75013,
"reduceToExistingWithRefund": 60013,
"emptyToExistingWithRefund": 52539,
"emptyToNewWithRefund": 60077,
"reduceApprovalReducingToNewWithRefund": 86241,
"reduceApprovalReducingToExistingWithRefund": 71241,
"reduceApprovalEmptyingToNewWithRefund": 71305,
"reduceApprovalEmptyingToExistingWithRefund": 58121,
"emptyApprovalReducingToNewWithRefund": 71241,
"emptyApprovalReducingToExistingWithRefund": 58153,
"emptyApprovalEmptyingToNewWithRefund": 65653,
"emptyApprovalEmptyingToExistingWithRefund": 58153,
"approve50WithRefund": 61430,
"reduceToBurnWithRefund": 102087,
"emptyToBurnWithRefund": 81076,
"burnMicroDollarWithRefund": 117087,
"reduceToBurnWithChangeWithRefund": 102151,
"emptyToBurnWithChangeWithRefund": 87151
"reduceToBurnWithRefund": 101713,
"emptyToBurnWithRefund": 80889,
"burnMicroDollarWithRefund": 116713,
"reduceToBurnWithChangeWithRefund": 101777,
"emptyToBurnWithChangeWithRefund": 86777
}
2 changes: 1 addition & 1 deletion registry
3 changes: 2 additions & 1 deletion test/CompliantToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import standardTokenTests from './token/StandardToken';
import basicTokenTests from './token/BasicToken';
const Registry = artifacts.require('RegistryMock')

const writeAttributeFor = require('./helpers/writeAttributeFor.js')
const bytes32 = require('./helpers/bytes32.js')
const BN = web3.utils.toBN;
import assertBalance from './helpers/assertBalance'
Expand Down Expand Up @@ -109,7 +110,7 @@ function compliantTokenTests([owner, oneHundred, anotherAccount], transfersToZer

describe('CanWriteTo-', function (){
beforeEach(async function () {
const canWriteToKYCAttribute = await this.registry.writeAttributeFor.call(bytes32("hasPassedKYC/AML"))
const canWriteToKYCAttribute = writeAttributeFor(bytes32("hasPassedKYC/AML"))
await this.registry.setAttribute(oneHundred, canWriteToKYCAttribute, 1, notes, { from: owner })
})

Expand Down
3 changes: 2 additions & 1 deletion test/DepositToken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const AllowanceSheet = artifacts.require("AllowanceSheet")
const ForceEther = artifacts.require("ForceEther")
const DepositAddressRegistrar = artifacts.require("DepositAddressRegistrar")

const writeAttributeFor = require('./helpers/writeAttributeFor.js')
const bytes32 = require('./helpers/bytes32.js')
const BN = web3.utils.toBN;

Expand Down Expand Up @@ -102,7 +103,7 @@ contract('DepositToken', function (accounts) {
describe('deposit token works with deposit registrar', function(){
beforeEach(async function () {
this.registrar = await DepositAddressRegistrar.new(this.registry.address, {from: owner})
const canWriteToDepositAddress = await this.registry.writeAttributeFor.call(bytes32("isDepositAddress"))
const canWriteToDepositAddress = writeAttributeFor(bytes32("isDepositAddress"))
await this.registry.setAttributeValue(this.registrar.address, canWriteToDepositAddress, 1, { from: owner })
})

Expand Down
11 changes: 11 additions & 0 deletions test/helpers/writeAttributeFor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const canWriteTo = Buffer.from(web3.utils.sha3("canWriteTo-").slice(2), 'hex');

function writeAttributeFor(attribute) {
let bytes = Buffer.from(attribute.slice(2), 'hex');
for (let index = 0; index < canWriteTo.length; index++) {
bytes[index] ^= canWriteTo[index];
}
return web3.utils.sha3('0x' + bytes.toString('hex'));
}

module.exports = writeAttributeFor;

0 comments on commit 081e396

Please sign in to comment.