Skip to content

Commit

Permalink
Test ERC20 contracts must also be released
Browse files Browse the repository at this point in the history
As we continue to go down the rabbit hole of getting this entire testing
suite running elsewhere we need to include the ERC20 test contracts
themselves and add similar path logic to the contract deployer as we
have to the rust code.
  • Loading branch information
jkilpatr committed Feb 11, 2021
1 parent c7beb15 commit e054298
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/automated-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
run: cd solidity && npm ci && npm run typechain

- name: Build contract deployment script into a static binary
run: cd solidity && npm ci && npm run compile-deployer
run: cd solidity && npm ci && npm run compile-deployer

- name: Build Rust x86_64
run: |
cargo install cross
cd orchestrator
cross build --target x86_64-unknown-linux-musl --release --all
# now that the code has built create the release and start uploading
- name: Create Release
id: create_release
Expand Down Expand Up @@ -138,6 +138,37 @@ jobs:
asset_name: Peggy.json
asset_content_type: application/bin

- name: Upload Gravity Ethereum test artifact A
id: upload-solidity-test-a
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /peggy/solidity/artifacts/contracts/TestERC20A.sol/TestERC20A.json
asset_name: TestERC20A.json
asset_content_type: application/bin
- name: Upload Gravity Ethereum test artifact B
id: upload-solidity-test-b
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /peggy/solidity/artifacts/contracts/TestERC20B.sol/TestERC20B.json
asset_name: TestERC20B.json
asset_content_type: application/bin
- name: Upload Gravity Ethereum test artifact C
id: upload-solidity-test-c
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /peggy/solidity/artifacts/contracts/TestERC20C.sol/TestERC20C.json
asset_name: TestERC20C.json
asset_content_type: application/bin

- name: Upload contract deployer
id: upload-contract-deployer
uses: actions/upload-release-asset@v1
Expand Down
37 changes: 34 additions & 3 deletions solidity/contract-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,50 @@ async function deploy() {

if (args["test-mode"] == "True" || args["test-mode"] == "true") {
console.log("Test mode, deploying ERC20 contracts");
const { abi, bytecode } = getContractArtifacts("/peggy/solidity/artifacts/contracts/TestERC20A.sol/TestERC20A.json");

// this handles several possible locations for the ERC20 artifacts
var erc20_a_path: string
var erc20_b_path: string
var erc20_c_path: string
const main_location_a = "/peggy/solidity/artifacts/contracts/TestERC20A.sol/TestERC20A.json"
const main_location_b = "/peggy/solidity/artifacts/contracts/TestERC20B.sol/TestERC20B.json"
const main_location_c = "/peggy/solidity/artifacts/contracts/TestERC20C.sol/TestERC20C.json"
const alt_location_1_a = "/solidity/TestERC20A.json"
const alt_location_1_b = "/solidity/TestERC20B.json"
const alt_location_1_c = "/solidity/TestERC20C.json"
const alt_location_2_a = "TestERC20A.json"
const alt_location_2_b = "TestERC20B.json"
const alt_location_2_c = "TestERC20C.json"
if (fs.existsSync(main_location_a)) {
erc20_a_path = main_location_a
erc20_b_path = main_location_b
erc20_c_path = main_location_c
} else if (fs.existsSync(alt_location_1_a)) {
erc20_a_path = alt_location_1_a
erc20_b_path = alt_location_1_b
erc20_c_path = alt_location_1_c
} else if (fs.existsSync(alt_location_2_a)) {
erc20_a_path = alt_location_2_a
erc20_b_path = alt_location_2_b
erc20_c_path = alt_location_2_c
} else {
console.log("Test mode was enabled but the ERC20 contracts can't be found!")
exit(1)
}

const { abi, bytecode } = getContractArtifacts(erc20_a_path);
const erc20Factory = new ethers.ContractFactory(abi, bytecode, wallet);
const testERC20 = (await erc20Factory.deploy()) as TestERC20A;
await testERC20.deployed();
const erc20TestAddress = testERC20.address;
console.log("ERC20 deployed at Address - ", erc20TestAddress);
const { abi: abi1, bytecode: bytecode1 } = getContractArtifacts("/peggy/solidity/artifacts/contracts/TestERC20B.sol/TestERC20B.json");
const { abi: abi1, bytecode: bytecode1 } = getContractArtifacts(erc20_b_path);
const erc20Factory1 = new ethers.ContractFactory(abi1, bytecode1, wallet);
const testERC201 = (await erc20Factory1.deploy()) as TestERC20B;
await testERC201.deployed();
const erc20TestAddress1 = testERC201.address;
console.log("ERC20 deployed at Address - ", erc20TestAddress1);
const { abi: abi2, bytecode: bytecode2 } = getContractArtifacts("/peggy/solidity/artifacts/contracts/TestERC20C.sol/TestERC20C.json");
const { abi: abi2, bytecode: bytecode2 } = getContractArtifacts(erc20_c_path);
const erc20Factory2 = new ethers.ContractFactory(abi2, bytecode2, wallet);
const testERC202 = (await erc20Factory2.deploy()) as TestERC20C;
await testERC202.deployed();
Expand Down

0 comments on commit e054298

Please sign in to comment.