-
Notifications
You must be signed in to change notification settings - Fork 15
/
fungible_asset_client_test.go
85 lines (66 loc) · 2.45 KB
/
fungible_asset_client_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package aptos
/* TODO: Re-enable when running on localnet
func TestClient(t *testing.T) {
if testing.Short() {
t.Skip("integration test expects network connection to mainnet")
}
// Create a new Aptos client
aptosClient, err := NewClient(MainnetConfig)
assert.NoError(t, err)
// Owner address
ownerAddress := AccountAddress{}
err = ownerAddress.ParseStringRelaxed(types.defaultOwner)
assert.NoError(t, err)
// TODO: This flow seems awkward and I made mistakes by running Parse on the same address multiple times
metadataAddress := AccountAddress{}
err = metadataAddress.ParseStringRelaxed(types.defaultMetadata)
assert.NoError(t, err)
primaryStoreAddress := AccountAddress{}
err = primaryStoreAddress.ParseStringRelaxed(types.defaultStore)
assert.NoError(t, err)
// Create a fungible asset client
faClient, err := NewFungibleAssetClient(aptosClient, metadataAddress)
assert.NoError(t, err)
// Primary store by direct access
balance, err := faClient.Balance(primaryStoreAddress)
assert.NoError(t, err)
println("BALANCE: ", balance)
name, err := faClient.Name()
assert.NoError(t, err)
println("NAME: ", name)
symbol, err := faClient.Symbol()
assert.NoError(t, err)
println("Symbol: ", symbol)
supply, err := faClient.Supply()
assert.NoError(t, err)
println("Supply: ", supply.String())
maximum, err := faClient.Maximum()
assert.NoError(t, err)
println("Maximum: ", maximum.String())
storeExists, err := faClient.StoreExists(primaryStoreAddress)
assert.NoError(t, err)
assert.True(t, storeExists)
// This should hold
storeNotExist, err := faClient.StoreExists(types.AccountOne)
assert.NoError(t, err)
assert.False(t, storeNotExist)
storeMetadataAddress, err := faClient.StoreMetadata(primaryStoreAddress)
assert.NoError(t, err)
assert.Equal(t, metadataAddress, storeMetadataAddress)
decimals, err := faClient.Decimals()
assert.NoError(t, err)
println("DECIMALS: ", decimals)
storePrimaryStoreAddress, err := faClient.PrimaryStoreAddress(ownerAddress)
assert.NoError(t, err)
assert.Equal(t, primaryStoreAddress, storePrimaryStoreAddress)
primaryStoreExists, err := faClient.PrimaryStoreExists(ownerAddress)
assert.NoError(t, err)
assert.True(t, primaryStoreExists)
// Primary store by default
primaryBalance, err := faClient.PrimaryBalance(ownerAddress)
assert.NoError(t, err)
println("PRIMARY BALANCE: ", primaryBalance)
isFrozen, err := faClient.IsFrozen(primaryStoreAddress)
assert.NoError(t, err)
assert.False(t, isFrozen
}*/