/
test.go
46 lines (34 loc) · 896 Bytes
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"log"
"strconv"
"github.com/oat9002/auto-compound/config"
"github.com/oat9002/auto-compound/services/crypto"
"github.com/oat9002/auto-compound/utils"
)
func executeTest(conf config.Config) {
network, chainId := conf.GetBscNetworkAndChainId()
clientService := crypto.NewClientService()
client, err := clientService.GetClient(network)
if err != nil {
log.Fatal(err)
return
}
testContract, err := crypto.NewTestContractService(client, uint64(chainId), conf.GasLimit, conf.GasPriceThreshold)
if err != nil {
log.Fatal(err)
return
}
transaction, err := testContract.Increase(conf.UserPrivateKey)
if err != nil {
log.Fatal(err)
return
}
log.Println("Get GasFee")
gasFee, err := utils.GetGasFee(client, transaction.Hash())
if err != nil {
log.Fatal(err)
return
}
log.Println("gas fee: " + strconv.FormatFloat(gasFee, 'e', 6, 64))
}