-
Notifications
You must be signed in to change notification settings - Fork 32
/
mock_test.go
51 lines (38 loc) · 1.12 KB
/
mock_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
47
48
49
50
51
package mocks_test
import (
"context"
"github.com/ethereum/go-ethereum/crypto"
"github.com/richardwilkes/toolbox/collection"
. "github.com/stretchr/testify/assert"
"github.com/synapsecns/sanguine/ethergo/mocks"
"testing"
)
func TestMockAccount(t *testing.T) {
account := mocks.MockAccount(t)
address := crypto.PubkeyToAddress(account.PrivateKey.PublicKey)
Equal(t, address, account.Address)
}
func TestMockAddress(t *testing.T) {
// make sure addresses are unique
stringSet := collection.Set[string]{}
const genCount = 100
for i := 0; i < genCount; i++ {
stringSet.Add(mocks.MockAddress().String())
}
Equal(t, genCount, len(stringSet.Values()))
}
func TestGetMockTxes(t *testing.T) {
const testTxCount = 10
mockTxes := mocks.GetMockTxes(context.Background(), t, testTxCount, 0)
// make sure txes are unique
txSet := collection.Set[string]{}
jsonSet := collection.Set[string]{}
for _, tx := range mockTxes {
raw, err := tx.MarshalJSON()
Nil(t, err)
jsonSet.Add(string(raw))
txSet.Add(tx.Hash().String())
}
Equal(t, testTxCount, len(txSet.Values()))
Equal(t, testTxCount, len(jsonSet.Values()))
}