-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a small script for testing deployments framework
- Loading branch information
1 parent
f2455fa
commit 80dc7bc
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}; |