update test contract

This commit is contained in:
Roy Crihfield 2024-04-23 19:30:22 +08:00
parent 9c3d8b353e
commit c6838838c1
7 changed files with 1055 additions and 1134 deletions

View File

@ -1,18 +1,13 @@
CONTRACTS_DIR := ./test/contract/contracts
CONTRACTS_OUTPUT_DIR := ./internal/testdata/build
GINKGO := go run github.com/onsi/ginkgo/v2/ginkgo
CONTRACTS := GLDToken Test
contracts: $(CONTRACTS_OUTPUT_DIR)/Test.bin $(CONTRACTS_OUTPUT_DIR)/Test.abi
contracts: $(foreach C,$(CONTRACTS), $(CONTRACTS_OUTPUT_DIR)/$C.bin $(CONTRACTS_OUTPUT_DIR)/$C.abi)
.PHONY: contracts
# Solidity 0.8.20 defaults to the Shanghai fork which includes the PUSH0 opcode
# which our testnet doesn't yet support, so use Paris.
$(CONTRACTS_OUTPUT_DIR)/%.bin $(CONTRACTS_OUTPUT_DIR)/%.abi: $(CONTRACTS_DIR)/%.sol
solc $< --abi --bin -o $(CONTRACTS_OUTPUT_DIR) --overwrite --evm-version=paris
test: contracts
$(GINKGO) -v -r ./validator_test
go test -p 1 -v ./pkg/...
.PHONY: test
clean:

View File

@ -1,8 +1,5 @@
# Downgrade from 18.16, see https://github.com/NomicFoundation/hardhat/issues/3877
FROM node:18.15-slim
ARG ETH_ADDR
ENV ETH_ADDR $ETH_ADDR
FROM node:20-slim
WORKDIR /usr/src/app
COPY package*.json ./

View File

@ -1,11 +1,16 @@
pragma solidity ^0.8.0;
pragma solidity ^0.8.25;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 {
constructor() ERC20("Gold", "GLD") {
_mint(msg.sender, 1000000000000000000000);
}
function destroy() public {
selfdestruct(payable(msg.sender));
(bool ok, ) = payable(msg.sender).call{value: address(this).balance}("");
require(ok, "ETH transfer failed");
_burn(msg.sender, balanceOf(msg.sender));
}
}

View File

@ -23,6 +23,7 @@ contract Test {
}
function close() public onlyOwner {
owner.transfer(address(this).balance);
(bool ok, ) = owner.call{value: address(this).balance}("");
require(ok, "ETH transfer failed");
}
}

View File

@ -28,9 +28,8 @@ if (process.env.DEPLOYER_PRIVATE_KEY) {
module.exports = {
solidity: {
version: '0.8.20',
version: "0.8.25",
settings: {
evmVersion: 'paris', // see Makefile
outputSelection: {
'*': {
'*': [

File diff suppressed because it is too large Load Diff

View File

@ -11,9 +11,10 @@
"license": "ISC",
"description": "Solidity contract deployment server for integration testing",
"dependencies": {
"@openzeppelin/contracts": "^4.0.0",
"fastify": "^4.0.0",
"hardhat": "^2.14.0"
"@openzeppelin/contracts": "^5.0.2",
"fastify": "^4.26.2",
"hardhat": "^2.22.3",
"solidity-create2-deployer": "^0.4.0"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.2.3",