Skip to content

Commit

Permalink
setup example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Dec 25, 2023
1 parent ed85639 commit bae0152
Show file tree
Hide file tree
Showing 37 changed files with 7,979 additions and 161 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
# private gopath
/.build/

package.json
/node_modules/

/.vscode/
/vendor/

.fake_gopath_suffix
.fake_gopath_suffix
6 changes: 6 additions & 0 deletions .idea/ktfmt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/thor.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

185 changes: 128 additions & 57 deletions .idea/workspace.xml

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions integration_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json
7 changes: 7 additions & 0 deletions integration_tests/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": "hardhat/register",
"timeout": 40000,
"slow": 20000,
"parallel": true,
"_": ["test/**/*.ts"]
}
13 changes: 13 additions & 0 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts
```
67 changes: 0 additions & 67 deletions integration_tests/config/genesis.json

This file was deleted.

16 changes: 0 additions & 16 deletions integration_tests/config/start.sh

This file was deleted.

25 changes: 25 additions & 0 deletions integration_tests/contracts/Storage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.19;

/**
* @title Storage
* @dev Store & retrieve value in a variable
*/
contract Storage {

uint256 private number;

event StoreEvent(address owner);

function store(uint256 num) public {
require(num < 100, "Number must be < 100");

emit StoreEvent(msg.sender);
number = num;
}

function retrieve() public view returns (uint256){
return number;
}
}
26 changes: 26 additions & 0 deletions integration_tests/contracts/VIP180.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface VIP180 {
function name() external view returns (string memory);

function symbol() external view returns (string memory);

function decimals() external view returns (uint8);

function totalSupply() external view returns (uint256);

function balanceOf(address _owner) external view returns (uint256);

function transfer(address _to, uint256 _value) external;

function transferFrom(address _from, address _to, uint256 _value) external;

function approve(address _spender, uint256 _value) external;

function allowance(address _owner, address _spender) external view returns (uint256);

event Transfer(address indexed _from, address indexed _to, uint256 _value);

event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
29 changes: 29 additions & 0 deletions integration_tests/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

import '@nomiclabs/hardhat-truffle5';
import '@vechain/hardhat-vechain'
import '@vechain/hardhat-ethers'

// use mocha config from .mocharc.json so we have common config between hardhat and mocha
const mochaConfig = require('./.mocharc.json')
delete mochaConfig.require

const config: HardhatUserConfig = {
defaultNetwork: "vechain",
solidity: "0.8.19",
mocha: mochaConfig,
networks: {
hardhat: {},
vechain: {
url: "http://127.0.0.1:8669",
accounts: {
mnemonic: "denial kitchen pet squirrel other broom bar gas better priority spoil cross",
count: 100,
},
gas: 10000000
}
}
};

export default config;
11 changes: 11 additions & 0 deletions integration_tests/helpers/clauses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {contractAddresses, contracts} from "./contracts"

export const fungible = {
balanceOf: (address: string): Connex.VM.Clause => {
return {
to: contractAddresses.VTHO,
value: 0,
data: contracts.VTHO.interface.encodeFunctionData("balanceOf", [address])
}
}
}
Loading

0 comments on commit bae0152

Please sign in to comment.