Skip to content

Commit

Permalink
Add a small script for testing deployments framework
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Nov 28, 2020
1 parent f2455fa commit 80dc7bc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
19 changes: 19 additions & 0 deletions contracts-test/TestOwnedContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.6.12;
import "../contracts/infrastructure/base/Owned.sol";

/**
* @title TestOwnedContract
* @notice Represents an arbitrary contract implementing Owned.
*/
contract TestOwnedContract is Owned {

uint256 public state;

event StateSet(uint256 indexed _state, uint256 indexed _value);

function setStateRestricted(uint256 _state) public onlyOwner payable {
state = _state;
emit StateSet(_state, msg.value);
}
}
39 changes: 39 additions & 0 deletions deployment/0_limited_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* global artifacts */
global.web3 = web3;
const chai = require("chai");
const BN = require("bn.js");
const bnChai = require("bn-chai");

const { expect } = chai;
chai.use(bnChai(BN));

const TestOwnedContract = artifacts.require("TestOwnedContract");
const MultiSig = artifacts.require("MultiSigWallet");

const deployManager = require("../utils/deploy-manager.js");
const MultisigExecutor = require("../utils/multisigexecutor.js");

async function main() {
const { deploymentAccount, configurator } = await deployManager.getProps();
console.log("deploymentAccount", deploymentAccount);
const { config } = configurator;

const testContractWrapper = await TestOwnedContract.new();
console.log("TestOwnedContract created at", testContractWrapper.address);

await testContractWrapper.changeOwner(config.contracts.MultiSigWallet);
console.log("Set the MultiSig as the owner of TestOwnedContract");

const MultiSigWrapper = await MultiSig.at(config.contracts.MultiSigWallet);
const multisigExecutor = new MultisigExecutor(MultiSigWrapper, deploymentAccount, config.multisig.autosign);
await multisigExecutor.executeCall(testContractWrapper, "setStateRestricted", [99]);
const stateValue = await testContractWrapper.state();
expect(stateValue).to.eq.BN(99);

console.log("## completed deployment script 7 ##");
}

// For truffle exec
module.exports = function (callback) {
main().then(() => callback()).catch((err) => callback(err));
};

0 comments on commit 80dc7bc

Please sign in to comment.