Commit 0f3a364c authored by duanjinfei's avatar duanjinfei

add print log

parent 7d098078
......@@ -108,7 +108,7 @@ func NrContractCoinTranCase(txCount int, testAccArr *tool.AccArrFormat, contract
if sendBeforeBal == nil {
return nil, nil
}
for i := 0; i < 2; i++ {
for i := 0; i < txCount; i++ {
from := testAccArr.FromAddr[i]
to := testAccArr.ToAddr[i]
fromBal := util.GetAccBal(client, from)
......@@ -143,10 +143,10 @@ func NrContractCoinTranCase(txCount int, testAccArr *tool.AccArrFormat, contract
if sendAfterBal == nil {
res = false
}
if sendBeforeBal.Sub(sendBeforeBal, sendAfterBal).Cmp(amount.Mul(amount, big.NewInt(int64(2)))) != 0 {
if sendBeforeBal.Sub(sendBeforeBal, sendAfterBal).Cmp(big.NewInt(1).Mul(amount, big.NewInt(int64(txCount)))) != 0 {
res = false
}
for i := 0; i < 2; i++ {
for i := 0; i < txCount; i++ {
from := testAccArr.FromAddr[i]
to := testAccArr.ToAddr[i]
fromBal := util.GetAccBal(client, from)
......@@ -232,7 +232,7 @@ func NrContractOneCoinTranCase(txCount int, testAccArr *tool.AccArrFormat, contr
if sendAfterBal == nil {
res = false
}
if sendBeforeBal.Sub(sendBeforeBal, sendAfterBal).Cmp(amount.Mul(amount, big.NewInt(int64(txCount)))) != 0 {
if sendBeforeBal.Sub(sendBeforeBal, sendAfterBal).Cmp(big.NewInt(1).Mul(amount, big.NewInt(int64(txCount)))) != 0 {
res = false
}
for i := 0; i < txCount; i++ {
......@@ -381,6 +381,7 @@ func NrErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap map
}
beforeToAddrErc20Bal := make(map[common.Address]*big.Int, 0)
beforeToken20Bal, err := erc20Contract.BalanceOf(&bind.CallOpts{}, contractMap[constant.TOKEN20_TRANSFER])
log.Info("Send before contract address erc20 balance: ", contractMap[constant.TOKEN20_TRANSFER], " is :", beforeToken20Bal.String())
if err != nil {
log.Error("Get token20ContractBal erc20 balanceOf error:", err.Error())
return nil, nil
......@@ -393,6 +394,7 @@ func NrErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap map
auth.NoSend = true
erc20Trade.ToAddr = []common.Address{testAccArr.ToAddr[i]}
toBal, err := erc20Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive before to address erc20 balance: ", testAccArr.ToAddr[i], " is :", toBal.String())
if err != nil {
log.Error("Get erc20 balanceOf error:", err.Error())
return nil, nil
......@@ -420,6 +422,7 @@ func NrErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap map
verify := func() bool {
res := true
afterToken20Bal, err := erc20Contract.BalanceOf(&bind.CallOpts{}, contractMap[constant.TOKEN20_TRANSFER])
log.Info("Verify Erc20 balance: ", contractMap[constant.TOKEN20_TRANSFER], "is: ", afterToken20Bal.String())
if err != nil {
log.Error("Get erc20 balanceOf error:", err.Error())
res = false
......@@ -429,6 +432,7 @@ func NrErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap map
}
for i := 0; i < txCount; i++ {
of, err := erc20Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Verify Erc20 balance: ", testAccArr.ToAddr[i], "is: ", of.String())
if err != nil {
log.Error("Get erc20 balanceOf error:", err.Error())
res = false
......@@ -461,7 +465,7 @@ func NrOneErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap
}
beforeToAddrErc20Bal := make(map[common.Address]*big.Int, 0)
beforeToken20Bal, err := erc20Contract.BalanceOf(&bind.CallOpts{}, contractMap[constant.TOKEN20_TRANSFER])
log.Info("beforeToken20Bal:", beforeToken20Bal.String())
log.Info("Send beforeToken20Bal:", contractMap[constant.TOKEN20_TRANSFER], " is: ", beforeToken20Bal.String())
if err != nil {
log.Error("Get token20ContractBal erc20 balanceOf error:", err.Error())
return nil, nil
......@@ -473,6 +477,7 @@ func NrOneErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap
}
oneErc20Trade.ToAddr = []common.Address{testAccArr.ToAddr[i]}
toBal, err := erc20Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive beforeToken20Bal:", testAccArr.ToAddr[i], " is: ", toBal.String())
if err != nil {
log.Error("Get erc20 balanceOf error:", err.Error())
return nil, nil
......@@ -493,12 +498,14 @@ func NrOneErc20TranCase(txCount int, testAccArr *tool.AccArrFormat, contractMap
verify := func() bool {
res := true
afterToken20Bal, err := erc20Contract.BalanceOf(&bind.CallOpts{}, contractMap[constant.TOKEN20_TRANSFER])
log.Info("Send after erc20 balance:", contractMap[constant.TOKEN20_TRANSFER], " is: ", afterToken20Bal.String())
if err != nil {
log.Error("Get token20ContractBal erc20 balanceOf error:", err.Error())
res = false
}
for i := 0; i < txCount; i++ {
of, err := erc20Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive after erc20 balance:", testAccArr.ToAddr[i], " is: ", of.String())
if err != nil {
log.Error("Get erc20 balanceOf error:", err.Error())
res = false
......@@ -538,11 +545,13 @@ func NrErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrFormat
}
erc721Trade.ToAddr = testAccArr.ToAddr[i]
toErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive before erc721 to balance:", testAccArr.ToAddr[i], " is: ", toErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
return nil, nil
}
fromErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.FromAddr[i])
log.Info("Send before erc721 from balance:", testAccArr.FromAddr[i], " is: ", fromErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
return nil, nil
......@@ -569,6 +578,7 @@ func NrErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrFormat
res := true
for i := 0; i < txCount; i++ {
toErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive after erc721 from balance:", testAccArr.ToAddr[i], " is: ", toErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
res = false
......@@ -577,6 +587,7 @@ func NrErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrFormat
res = false
}
fromErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.FromAddr[i])
log.Info("Send after erc721 from balance:", testAccArr.FromAddr[i], " is: ", fromErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
res = false
......@@ -614,11 +625,13 @@ func NrOneErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrFor
oneErc721Trade.ToAddr = testAccArr.ToAddr[i]
oneErc721Trade.FromAddr = testAccArr.FromAddr[i]
toErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive before erc721 to balance:", testAccArr.ToAddr[i], " is: ", toErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
return nil, nil
}
fromErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.FromAddr[i])
log.Info("Send before erc721 from balance:", testAccArr.FromAddr[i], " is: ", fromErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
return nil, nil
......@@ -643,6 +656,7 @@ func NrOneErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrFor
res := true
for i := 0; i < txCount; i++ {
toErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.ToAddr[i])
log.Info("Receive after erc721 to balance:", testAccArr.ToAddr[i], " is: ", toErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
res = false
......@@ -651,6 +665,7 @@ func NrOneErc721TranCase(startIndex int, txCount int, testAccArr *tool.AccArrFor
res = false
}
fromErc721Bal, err := erc721Contract.BalanceOf(&bind.CallOpts{}, testAccArr.FromAddr[i])
log.Info("Send after erc721 from balance:", testAccArr.FromAddr[i], " is: ", fromErc721Bal.String())
if err != nil {
log.Error("Get erc721 bal error:", err.Error())
res = false
......
......@@ -164,6 +164,11 @@ func InitErc721AccMint(txArr []*types.Transaction, nonce uint64, contractLen int
tokenIds = append(tokenIds, big.NewInt(int64(i)))
}
auth.Nonce = big.NewInt(int64(nonce))
of, err := newERC721.BalanceOf(&bind.CallOpts{}, tool.Cfg.DeployAddr)
if err != nil {
return nil, 0
}
log.Info("Erc721 Mint before deploy address balance of", tool.Cfg.DeployAddr, " is: ", of.String())
tx, err = newERC721.BatchMint(auth, tool.Cfg.DeployAddr, tokenIds)
if err != nil {
log.Error("Init account - erc721 mint err:", err.Error())
......@@ -514,6 +519,6 @@ func SendTransaction(trans []*types.Transaction) {
}
log.Info("Input count:", i)
}
time.Sleep(time.Second * 120)
time.Sleep(time.Second * 60)
log.Info("Send tran successful")
}
......@@ -41,7 +41,7 @@ func TestGetContractAbi(t *testing.T) {
}
log.Info("balance:", balance.String())
receipt, err := client.TransactionReceipt(context.Background(), common.HexToHash("0x9699843dbe3a809a928ad7a68c009c7c2316bce09566ea9a579fae33e899c95b"))
receipt, err := client.TransactionReceipt(context.Background(), common.HexToHash("0x01f33987e4732300c8b3f2d2e7c9946ced3be5a0a649fdcf04817954c066e5ca"))
if err != nil {
log.Fatal("Get receipt error:", err.Error())
return
......@@ -77,8 +77,8 @@ func TestGetErc721Balance(t *testing.T) {
log.Fatal(err)
}
// 从合约地址获取合约代码
contractAddress := common.HexToAddress("0x450260F10b2D55b785037388fA3aA3b2232cC9F4")
accountAddr := common.HexToAddress("0x40EC4256fcBCA69CdbAc942594caeC79FBE10494")
contractAddress := common.HexToAddress("0x408d8a2e22265edb60bc98f59d7a458f2cefc638")
accountAddr := common.HexToAddress("0xe2bA4B27E835f3D5A8f74B53aD6b8b6264D3F501")
newERC721, err := erc721.NewERC721(contractAddress, client)
if err != nil {
......@@ -89,6 +89,14 @@ func TestGetErc721Balance(t *testing.T) {
return
}
log.Info("balance is :", of.String())
for i := 0; i < 100; i++ {
ownerOf, err := newERC721.OwnerOf(&bind.CallOpts{}, big.NewInt(int64(i)))
if err != nil {
log.Error("Error:", err.Error())
return
}
log.Info("ownerOf:", ownerOf.Hex())
}
}
func TestBigIntFunc(t *testing.T) {
......
......@@ -123,6 +123,7 @@ func GetAccountBalance(client *ethclient.Client) {
}
}()
}
addrChan <- tool.Cfg.DeployAddr
for i := 0; i < len(accountArr.FromAddr); i++ {
addrChan <- accountArr.FromAddr[i]
addrChan <- accountArr.ToAddr[i]
......
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