forked from tokencard/ethertest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
26 lines (21 loc) · 637 Bytes
/
utils.go
File metadata and controls
26 lines (21 loc) · 637 Bytes
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
package ethertest
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/core/types"
)
// OneEth is 10^18 Wei
var OneEth = big.NewInt(1000000000000000000)
// EthToWei converts ETH value to Wei
func EthToWei(amount int) *big.Int {
r := big.NewInt(1).Set(OneEth)
return r.Mul(r, big.NewInt(int64(amount)))
}
// IsSuccessful returns boolean indicating if the transaction was successful
func IsSuccessful(be TestBackend, tx *types.Transaction) (bool, error) {
r, err := be.TransactionReceipt(context.Background(), tx.Hash())
if err != nil {
return false, err
}
return r.Status == types.ReceiptStatusSuccessful, nil
}