Commit c1ac0912 authored by duanjinfei's avatar duanjinfei

four commit

parent c72a9be3
{
"deployAddr1": "0xe2bA4B27E835f3D5A8f74B53aD6b8b6264D3F501",
"deployPrv1": "115725efa0b457a764bb0b73b79a26605a54a5025d825b5a627f69354cdbbbf4",
"deployAddr": "0x40EC4256fcBCA69CdbAc942594caeC79FBE10494",
"deployPrv": "37871f094f89fc95599e73d72d3008c828bb76d0864759011fa14dbaf6cf3c06",
"rpcNode1": "http://192.168.1.125:50000",
"rpcNode": "http://15.161.177.5:26658",
"chainId1": 155,
"chainId": 256256,
"deployAddr": "0xe2bA4B27E835f3D5A8f74B53aD6b8b6264D3F501",
"deployPrv": "115725efa0b457a764bb0b73b79a26605a54a5025d825b5a627f69354cdbbbf4",
"deployAddr1": "0x40EC4256fcBCA69CdbAc942594caeC79FBE10494",
"deployPrv1": "37871f094f89fc95599e73d72d3008c828bb76d0864759011fa14dbaf6cf3c06",
"rpcNode": "http://54.72.101.87:50000",
"rpcNode1": "http://15.161.177.5:26658",
"chainId": 155,
"chainId1": 256256,
"goRoutine": 1,
"generateAccCount": 500,
"isDeployContract": false,
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ func main() {
// 转账交易case
if len(tool.Cfg.TransferType) != 0 {
accIndex := 0
accIndex := 12
nonceMap := util.GetAccountNonce(tool.Cfg.RpcNode)
arrFormat := tool.ParseAccountConfig("./config/account.json")
parseContractConfig := tool.ParseContractConfig("./config/contractConfig.json")
......
This diff is collapsed.
......@@ -73,8 +73,8 @@ func DeployContract(client *ethclient.Client, txRes []*types.Transaction) []*typ
}
auth.NoSend = true
auth.Value = big.NewInt(0)
auth.GasLimit = uint64(5000000000)
auth.GasPrice = big.NewInt(5000000000)
auth.GasLimit = uint64(4000000)
auth.GasPrice = big.NewInt(4000000)
nonce, err := client.NonceAt(context.Background(), tool.Cfg.DeployAddr, nil)
if err != nil {
log.Error("DeployTokenTransfer func get acc nonce err:", err)
......@@ -355,12 +355,12 @@ func GetTranFunc(caseType int, startIndex int, txCount int, nonceMap *sync.Map,
// 不相关-单层-Erc721转账
case 8:
{
return NrErc721TranCase(txCount, arr, contractArr[0], nonceMap, txArr, client)
return NrErc721TranCase(startIndex, txCount, arr, contractArr[0], nonceMap, txArr, client)
}
// 不相关-多层-Erc721转账
case 9:
{
return NrOneErc721TranCase(txCount, arr, contractArr[0], nonceMap, txArr, client)
return NrOneErc721TranCase(startIndex, txCount, arr, contractArr[0], nonceMap, txArr, client)
}
// 部分相关-普通转账-接受者相关
case 10:
......
This diff is collapsed.
......@@ -10,6 +10,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"math/big"
"strings"
"testing"
)
......@@ -47,13 +48,13 @@ func TestGetContractAbi(t *testing.T) {
func TestGetErc20Balance(t *testing.T) {
// 连接以太坊网络
client, err := ethclient.Dial("http://15.161.177.5:26658")
client, err := ethclient.Dial("http://54.72.101.87:50000")
if err != nil {
log.Fatal(err)
}
// 从合约地址获取合约代码
contractAddress := common.HexToAddress("0x91f2c122c8060258605c287cea0bdda056b7b25d")
accountAddr := common.HexToAddress("0x4b0ae7ac4886e7c54e40529cc008df84407e5975")
contractAddress := common.HexToAddress("0x14f2567347beb8ed0fec95397940f17ef7a94541")
accountAddr := common.HexToAddress("0x812D866f7f558A7325c16B729286e0e661b9DB36")
newERC20, err := erc20.NewERC20(contractAddress, client)
if err != nil {
......@@ -86,3 +87,13 @@ func TestGetErc721Balance(t *testing.T) {
}
log.Info("balance is :", of.String())
}
func TestBigIntFunc(t *testing.T) {
//amount := big.NewInt(10000000000)
mul := big.NewInt(1).Mul(big.NewInt(10000000000000000), big.NewInt(2))
t.Log("amount:", mul.String())
}
......@@ -44,18 +44,28 @@ func HexToAddress(addr string) common.Address {
}
func GetTxReceipt(client *ethclient.Client, txArr []*types.Transaction) {
txChanel := make(chan common.Hash, 1000)
for i := 0; i < 8; i++ {
go func() {
select {
case hash := <-txChanel:
receipt, err := client.TransactionReceipt(context.Background(), hash)
if err != nil {
log.Error("Get tran receipt err:", err)
return
}
if receipt.Status == 0 {
log.Error("Receipt:", receipt)
} else {
log.Infof("Receipt: status: %d,gasUsed: %d", receipt.Status, receipt.GasUsed)
}
}
}()
}
for _, tx := range txArr {
receipt, err := client.TransactionReceipt(context.Background(), tx.Hash())
if err != nil {
log.Error("Get tran receipt err:", err)
return
}
if receipt.Status == 0 {
log.Error("Receipt:", receipt)
} else {
log.Infof("Receipt: status: %d,gasUsed: %d", receipt.Status, receipt.GasUsed)
}
txChanel <- tx.Hash()
}
time.Sleep(time.Second * 10)
}
func GetAccountNonce(client *ethclient.Client) *sync.Map {
......@@ -115,7 +125,6 @@ func GetAccountBalance(client *ethclient.Client) {
select {
case addr := <-addrChan:
GetAccBal(client, addr)
log.Info("tool.Cfg.ContractMap[0][constant.ERC20]:", tool.Cfg.ContractMap[0][constant.ERC20])
GetAccountErc20BalanceOf(client, tool.Cfg.ContractMap[0][constant.ERC20], addr)
GetAccountErc721BalanceOf(client, tool.Cfg.ContractMap[0][constant.ERC721], addr)
atomic.AddInt32(&handleBalanceCount, 1)
......@@ -147,11 +156,11 @@ func GetAccountErc20BalanceOf(client *ethclient.Client, erc20Addr common.Address
log.Errorf("Get erc20 balance of failed err:%s", err.Error())
return
}
of, err = newERC20.Allowance(&bind.CallOpts{}, common.HexToAddress("0xfb1bF24c0C7e7C1B89c4A496aACf01aBF26C0B94"), toAddr)
if err != nil {
log.Errorf("Get erc20 balance of failed err:%s", err.Error())
return
}
//of, err = newERC20.Allowance(&bind.CallOpts{}, common.HexToAddress("0xfb1bF24c0C7e7C1B89c4A496aACf01aBF26C0B94"), toAddr)
//if err != nil {
// log.Errorf("Get erc20 balance of failed err:%s", err.Error())
// return
//}
log.Infof("%s erc20 balance of is: %s ", toAddr.Hash().Hex(), of.String())
}
......@@ -190,6 +199,7 @@ func ReadWriteCase(prv *ecdsa.PrivateKey, funcStr string, nonce *big.Int, readWr
}
auth.Nonce = nonce
auth.NoSend = true
auth.GasLimit = 500000
auth.GasPrice = big.NewInt(1000000000000)
tx := &types.Transaction{}
switch funcStr {
......@@ -269,6 +279,7 @@ func OneReadWriteCase(prv *ecdsa.PrivateKey, funcStr string, nonce *big.Int, rea
}
auth.Nonce = nonce
auth.NoSend = true
auth.GasLimit = 500000
auth.GasPrice = big.NewInt(1000000000000)
tx := &types.Transaction{}
switch funcStr {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment