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 27, 2020
1 parent f2455fa commit f0f7c30
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts-test/TestContract.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.6.12;
import "./TokenConsumer.sol";
import "../contracts/infrastructure/base/Owned.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/**
* @title TestContract
* @notice Represents an arbitrary contract.
* @author Olivier Vdb - <olivier@argent.xyz>
*/
contract TestContract {
contract TestContract is Owned {

uint256 public state;
TokenConsumer public tokenConsumer;
Expand All @@ -24,6 +25,11 @@ contract TestContract {
emit StateSet(_state, msg.value);
}

function setStateRestricted(uint256 _state) public onlyOwner payable {
state = _state;
emit StateSet(_state, msg.value);
}

function setStateAndPayToken(uint256 _state, address _erc20, uint256 _amount) public {
ERC20(_erc20).transferFrom(msg.sender, address(this), _amount);
state = _state;
Expand Down
33 changes: 33 additions & 0 deletions deployment/0_limited_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* global artifacts */
global.web3 = web3;

const TestContract = artifacts.require("TestContract");
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 TestContract.new();
console.log("TestContract created at", testContractWrapper.address);

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

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();
assert.equal(stateValue.toNumber(), 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 f0f7c30

Please sign in to comment.