Skip to content

Commit

Permalink
Speed up test suites with OZ and fix intermittent issues on CI (#255)
Browse files Browse the repository at this point in the history
Truffle tests are taking about 30-40 minutes to complete on CI, this PR introduces the OZ test-environment lib to enhance the test suites and speed up the testing process. The tests are now taking about 3-4 minutes to complete on Github CI.

Signed-off-by: Felipe Forbeck <[email protected]>

Co-authored-by: David Roon <[email protected]>
  • Loading branch information
fforbeck and adridadou authored Apr 19, 2021
1 parent 3d59e9e commit d70f4d4
Show file tree
Hide file tree
Showing 38 changed files with 32,989 additions and 39,046 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Codecov
name: Coverage

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- "*"
jobs:
coverage:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -32,12 +32,12 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
# - name: Install dependencies
# if: steps.cache-node-modules.outputs.cache-hit != 'true'
# run: npm ci

- name: Run Sol Coverage
run: npm run coverage
# - name: Run Sol Coverage
# run: npm run coverage

- name: Publish to Codecov.io
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
# - name: Publish to Codecov.io
# run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
9 changes: 3 additions & 6 deletions .github/workflows/lint.yml → .github/workflows/subgraph.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Subgraph

on:
push:
Expand All @@ -11,7 +11,7 @@ on:

jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -38,9 +38,6 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Run .sol and .md linter
run: npm run lint

- name: Run Truffle Compile
run: npm run compile-abi

Expand Down Expand Up @@ -69,4 +66,4 @@ jobs:

- name: Build subgraph
run: npm run build
working-directory: subgraph
working-directory: subgraph
16 changes: 11 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Test

on:
push:
Expand All @@ -11,15 +11,15 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: '12.22.x'

- name: Cache node modules
id: cache-node-modules
Expand All @@ -38,5 +38,11 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci

- name: Run tests
run: npm test
- name: Run Linter
run: npm run lint

- name: Compile Solidity Contracts
run: npm run compile

- name: Run Tests
run: npm test
39 changes: 10 additions & 29 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
module.exports = {
norpc: false,
compileCommand: "truffle compile",
testCommand:
"export ETHEREUM_RPC_PORT=8555 && truffle test --network coverage --timeout 10000",
skipFiles: [
// Skip config contracts
"Migration",
// Skip Test Contracts
"test/OLToken",
"test/PixelNFT",
"test/TestFairShareCalc",
"test/TestToken1",
"test/TestToken2",
// Skip openzeppelin contracts
"utils/ERC20",
"utils/IERC20",
"ERC721",
"IERC721",
"IERC721Receiver",
"IERC721Enumerable",
"IERC721Metadata",
"Address",
"Context",
"Counters",
"Strings",
"ERC165",
"IERC165",
"EnumerableSet",
],
norpc: true,
testCommand: "npm test",
compileCommand: "npm run compile",
providerOptions: {
default_balance_ether: "10000000000000000000000000",
},
mocha: {
fgrep: "[skip-on-coverage]", // tag to skip tests
invert: true,
},
};
2 changes: 1 addition & 1 deletion .solhintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/
contracts/test
contracts/test/
contracts/Migrations.sol
24 changes: 12 additions & 12 deletions contracts/adapters/TributeNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ contract TributeNFTContract is
revert("fallback revert");
}

function provideTribute(
DaoRegistry,
bytes32,
address,
address,
uint256,
address,
uint256
) external pure override {
revert("not supported operation");
}

/**
* @notice Configures the adapter for a particular DAO.
* @notice Registers the DAO internal token SHARES with the DAO Bank.
Expand All @@ -92,6 +80,18 @@ contract TributeNFTContract is
bank.registerPotentialNewInternalToken(SHARES);
}

function provideTribute(
DaoRegistry,
bytes32,
address,
address,
uint256,
address,
uint256
) external pure override {
revert("not supported operation");
}

/**
* @notice Creates a tribute proposal and escrows received token into the adapter.
* @dev Applicant address must not be reserved.
Expand Down
2 changes: 1 addition & 1 deletion contracts/guards/AdapterGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract contract AdapterGuard {
}

modifier reentrancyGuard(DaoRegistry dao) {
require(dao.lockedAt() < block.number, "reentrancy guard");
require(dao.lockedAt() != block.number, "reentrancy guard");
dao.lockSession();
_;
dao.unlockSession();
Expand Down
30 changes: 15 additions & 15 deletions docs/adapters/TributeNFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ Bank Extension Access Flags: `ADD_TO_BALANCE`.
receive() external payable
```

### function configureDao

```solidity
/**
* @notice Configures the adapter for a particular DAO.
* @notice Registers the DAO internal token SHARES with the DAO Bank.
* @dev Only adapters registered to the DAO can execute the function call (or if the DAO is in creation mode).
* @dev A DAO Bank extension must exist and be configured with proper access for this adapter.
* @param dao The DAO address.
*/
function configureDao(DaoRegistry dao)
external
onlyAdapter(dao)
```

### function provideTribute

Not implemented because the adapter does not handle ERC20 tokens.
Expand All @@ -95,21 +110,6 @@ function provideTribute(
) external pure override
```

### function configureDao

```solidity
/**
* @notice Configures the adapter for a particular DAO.
* @notice Registers the DAO internal token SHARES with the DAO Bank.
* @dev Only adapters registered to the DAO can execute the function call (or if the DAO is in creation mode).
* @dev A DAO Bank extension must exist and be configured with proper access for this adapter.
* @param dao The DAO address.
*/
function configureDao(DaoRegistry dao)
external
onlyAdapter(dao)
```

### function provideTributeNFT

```solidity
Expand Down
Loading

0 comments on commit d70f4d4

Please sign in to comment.