Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Jun 7, 2023
1 parent 73b2299 commit 1974628
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 52 deletions.
8 changes: 4 additions & 4 deletions darc-protocol/scripts/deployDARC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export async function deployDARC(): Promise<string> {


const signers = await ethers.getSigners();
for(let i = 0; i < signers.length; i++){
console.log("signer: " + signers[i].address);
}
// for(let i = 0; i < signers.length; i++){
// console.log("signer: " + signers[i].address);
// }

console.log("DARC address: ", darc.address);
// console.log("DARC address: ", darc.address);
await darc.deployed();
await darc.initialize();
return darc.address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const target2 = '0x90F79bf6EB2c4f870365E785982E1f101E93b906';

const target3 = '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65';

describe.only("test for batch add and enable plugins", function () {
describe("test for batch add and enable plugins", function () {


it ("batch batch add and enable plugins", async function () {
Expand Down Expand Up @@ -71,7 +71,7 @@ describe.only("test for batch add and enable plugins", function () {
ADDRESS_ARRAY: [],
STRING_ARRAY: [],
UINT256_2DARRAY: [],
ADDRESS_2DARRAY: [ [target1] ],
ADDRESS_2DARRAY: [ ["0x70997970C51812dc3A010C7d01b50e0d17dc79C8"] ],
STRING_2DARRAY: [],
}
};
Expand All @@ -96,7 +96,7 @@ describe.only("test for batch add and enable plugins", function () {
node_deny_target1
],
votingRuleIndex: 0,
note: "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC should not operate",
note: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8 should not operate",
bIsEnabled: true,
bIsInitialized: true,
bIsBeforeOperation: true,
Expand All @@ -105,10 +105,34 @@ describe.only("test for batch add and enable plugins", function () {
UINT256_2DARRAY: [],
ADDRESS_2DARRAY: []
}
}],
},
// {
// operatorAddress: programOperatorAddress,
// opcode: 1, // mint token
// param: {
// UINT256_ARRAY: [],
// ADDRESS_ARRAY: [],
// STRING_ARRAY: [],
// BOOL_ARRAY: [],
// VOTING_RULE_ARRAY: [],
// PARAMETER_ARRAY: [],
// PLUGIN_ARRAY: [],
// UINT256_2DARRAY: [
// [BigNumber.from(0), BigNumber.from(1)],
// [BigNumber.from(100)], // amount = 100
// ],
// ADDRESS_2DARRAY: [
// [target1],
// ]
// }
// }
],
}
);




// get darc address
const darcAddress = darc.address;

Expand All @@ -119,20 +143,20 @@ describe.only("test for batch add and enable plugins", function () {
* Account #1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 (10000 ETH)
Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
*/

let bIsException = false;
const signer_address1 = ethers.provider.getSigner(1);

const target_addr = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";
// get darc factory
const DarcFactory = await ethers.getContractFactory("DARC", signer_address1);
// attach darc contract
const darc2 = DarcFactory.attach(darcAddress);

// try to run a batch mint token instruction with target1 as the operator
try {
const result = darc2.entrance({
programOperatorAddress: target1,
const result = await darc2.entrance({
programOperatorAddress: target_addr,
operations: [{
operatorAddress: target1,
operatorAddress: target_addr,
opcode: 1, // mint token
param: {
UINT256_ARRAY: [],
Expand All @@ -147,57 +171,69 @@ describe.only("test for batch add and enable plugins", function () {
[BigNumber.from(100)], // amount = 100
],
ADDRESS_2DARRAY: [
[target1],
[target_addr],
]
}
}],
});
bIsException = false;

console.log(JSON.stringify(result));
}
catch (err) {
console.log(err);
bIsException = true;
}

// make sure that an exception is thrown
expect(bIsException).to.equal(true);

// make sure that no token is minted
const totalSupplyOfTokenClass0 = await darc2.getTokenOwners(BigNumber.from(0));
console.log(totalSupplyOfTokenClass0);

// try to run a batch mint token instruction with target1 as the operator
try {
const result = darc.entrance({
programOperatorAddress: programOperatorAddress,
operations: [{
operatorAddress: programOperatorAddress,
opcode: 1, // mint token
param: {
UINT256_ARRAY: [],
ADDRESS_ARRAY: [],
STRING_ARRAY: [],
BOOL_ARRAY: [],
VOTING_RULE_ARRAY: [],
PARAMETER_ARRAY: [],
PLUGIN_ARRAY: [],
UINT256_2DARRAY: [
[BigNumber.from(0)],
[BigNumber.from(100)], // amount = 100
],
ADDRESS_2DARRAY: [
[target1],
]
}
}],
});

console.log(JSON.stringify(result));
// make sure that no token is minted
const totalSupplyOfTokenClass0 = await darc2.getTokenOwners(BigNumber.from(0));
console.log(totalSupplyOfTokenClass0);
}
catch (err) {
console.log(err);
}
//console.log(totalSupplyOfTokenClass0);
expect(totalSupplyOfTokenClass0.length).to.equal(0);

// try to run a batch mint token instruction with target1 as the operator
try {
const result3 = await darc.entrance({
programOperatorAddress: programOperatorAddress,
operations: [{
operatorAddress: programOperatorAddress,
opcode: 1, // mint token
param: {
UINT256_ARRAY: [],
ADDRESS_ARRAY: [],
STRING_ARRAY: [],
BOOL_ARRAY: [],
VOTING_RULE_ARRAY: [],
PARAMETER_ARRAY: [],
PLUGIN_ARRAY: [],
UINT256_2DARRAY: [
[BigNumber.from(0)],
[BigNumber.from(100)], // amount = 100
],
ADDRESS_2DARRAY: [
[target1],
]
}
}],
});

bIsException = false;
}
catch (err) {
//console.log(err);
bIsException = true;
}

expect(bIsException).to.equal(false);

// then check the token owners from darc2
const totalSupplyOfTokenClass0_darc2 = await darc2.getTokenOwners(BigNumber.from(0));
//console.log(totalSupplyOfTokenClass0_darc2);

// // list all plugins
// const plugins = await darc.getPluginInfo();
// console.log(plugins);
expect (totalSupplyOfTokenClass0_darc2[0].toLowerCase()).equal(target1.toLowerCase());
});


Expand Down

0 comments on commit 1974628

Please sign in to comment.