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_DIR := ./test/contract/contracts
CONTRACTS_OUTPUT_DIR := ./internal/testdata/build 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 .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 test: contracts
$(GINKGO) -v -r ./validator_test go test -p 1 -v ./pkg/...
.PHONY: test .PHONY: test
clean: clean:

View File

@ -1,8 +1,5 @@
# Downgrade from 18.16, see https://github.com/NomicFoundation/hardhat/issues/3877 # Downgrade from 18.16, see https://github.com/NomicFoundation/hardhat/issues/3877
FROM node:18.15-slim FROM node:20-slim
ARG ETH_ADDR
ENV ETH_ADDR $ETH_ADDR
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY package*.json ./ 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"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 { contract GLDToken is ERC20 {
constructor() ERC20("Gold", "GLD") { constructor() ERC20("Gold", "GLD") {
_mint(msg.sender, 1000000000000000000000); _mint(msg.sender, 1000000000000000000000);
} }
function destroy() public { 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 { 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 = { module.exports = {
solidity: { solidity: {
version: '0.8.20', version: "0.8.25",
settings: { settings: {
evmVersion: 'paris', // see Makefile
outputSelection: { outputSelection: {
'*': { '*': {
'*': [ '*': [

File diff suppressed because it is too large Load Diff

View File

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