-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_token_account_activation_test.go
77 lines (63 loc) · 2.07 KB
/
sample_token_account_activation_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
package main_test
import (
. "erc20"
"erc20/lib/erc20burnable"
"erc20/lib/erc20detailed"
"erc20/lib/erc20mintable"
"erc20/lib/erc20ownable"
"erc20/lib/erc20pausable"
"github.com/hyperledger/fabric/core/chaincode/shim"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Account activation", func() {
const (
txID = `test-activation-id`
tokenName = `sample token name`
tokenSymbol = `(y)(y)`
tokenDecimals = `14`
//attributes matches the certs in /testutils
issuer = `Org1-child1`
fromOrg = `clientOrg1MSP`
fromSubject = `Org1-child1-client1`
toOrg = `clientOrg2MSP`
toSubject = `Org1-child1-client2`
ownerIssuer = `Org1`
ownerOrg = `sampleOrgMSP`
ownerSubject = `Org1-child1`
)
sampleToken := SampleToken{
&CustomBasicToken{},
&erc20ownable.Token{},
&erc20detailed.Token{},
&erc20mintable.Token{},
&erc20burnable.Token{},
&erc20pausable.Token{},
}
// var err error
var mockStub *shim.MockStub = shim.NewMockStub("mockStubNormal", &sampleToken)
// var initialTotalSupply *big.Int = Mul(big.NewInt(InitialMintAmount), Pow(10, StringToInt(tokenDecimals)))
// ownerID := ownerOrg + "," + ownerIssuer + "," + ownerSubject
// fromID := fromOrg + "," + issuer + "," + fromSubject
// toID := toOrg + "," + issuer + "," + toSubject
BeforeEach(func() {
mockStub.MockTransactionStart(txID)
})
AfterEach(func() {
mockStub.MockTransactionEnd(txID)
})
It("Should return error when getting balance of non-existent account", func() {
balance, err := sampleToken.GetBalanceOf(mockStub, []string{"fake-account"})
Expect(err.Error()).To(ContainSubstring("is not registered"))
Expect(balance).To(BeNil())
})
It("Should activate the fake account", func() {
err := sampleToken.Activate(mockStub, []string{"fake-account"}, sampleToken.GetBalanceOf)
Expect(err).To(BeNil())
})
It("Should now be able to get balance of fake account", func() {
balance, err := sampleToken.GetBalanceOf(mockStub, []string{"fake-account"})
Expect(err).To(BeNil())
Expect(balance.String()).To(Equal("0"))
})
})