-
Notifications
You must be signed in to change notification settings - Fork 5
/
chunk_test.go
125 lines (102 loc) · 3.81 KB
/
chunk_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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package main
import (
"fmt"
"path"
"testing"
"github.com/XDagger/xdagpool/kvstore"
"github.com/XDagger/xdagpool/payouts"
"github.com/XDagger/xdagpool/pool"
"github.com/XDagger/xdagpool/util"
"github.com/XDagger/xdagpool/xdago/common"
bip "github.com/XDagger/xdagpool/xdago/wallet"
)
func TestFieldTypes(t *testing.T) {
s := payouts.FieldChunkTypes(false, true, true, 10)
fmt.Println(s)
s = payouts.FieldChunkTypes(false, false, true, 11)
fmt.Println(s)
s = payouts.FieldChunkTypes(false, true, false, 6)
fmt.Println(s)
s = payouts.FieldChunkTypes(true, false, false, 5)
fmt.Println(s)
}
func TestChunkSign(t *testing.T) {
// init log file
// _ = os.Mkdir("../logs", os.ModePerm)
iLogFile := "logs/info.log"
eLogFile := "logs/error.log"
sLogFile := "logs/share.log"
bLogFile := "logs/block.log"
util.InitLog(iLogFile, eLogFile, sLogFile, bLogFile, 10)
wallet := bip.NewWallet(path.Join(".", common.BIP32_WALLET_FOLDER, common.BIP32_WALLET_FILE_NAME))
res := wallet.UnlockWallet("111")
if res && wallet.IsHdWalletInitialized() {
key := wallet.GetDefKey()
r, s, n := payouts.ChunkTranxSign("0000000000000000000000000000000000000000000000000000000000000000", key)
fmt.Println(r, s, n)
}
}
func TestChunkBlock(t *testing.T) {
to := []string{"4duPWMbYUgAifVYkKDCWxLvRRkSByf5gb", "Fve2AF8NrEPjNcAj5BABTBeqn7LW7WfeT", "Fii9BuhR1KogfNzWbtSH1YJgQQDwFMomK"}
value := []int64{2 * 1e9, 7 * 1e9, 15 * 1e9}
iLogFile := "logs/info.log"
eLogFile := "logs/error.log"
sLogFile := "logs/share.log"
bLogFile := "logs/block.log"
util.InitLog(iLogFile, eLogFile, sLogFile, bLogFile, 10)
wallet := bip.NewWallet(path.Join(".", common.BIP32_WALLET_FOLDER, common.BIP32_WALLET_FILE_NAME))
res := wallet.UnlockWallet("111")
if res && wallet.IsHdWalletInitialized() {
key := wallet.GetDefKey()
block, total := payouts.TransactionChunkBlock("Dd2KRkRceHtx7ep3qWHVAHEdjYoyPpAYx", to, "hello", value, key)
fmt.Println(total)
fmt.Println(block)
}
}
func TestChunkRpc(t *testing.T) {
to := []string{"4duPWMbYUgAifVYkKDCWxLvRRkSByf5gb", "Fve2AF8NrEPjNcAj5BABTBeqn7LW7WfeT", "2UqAZBFqA3CbWa6oTR3PYi6BW2wXGK9tY"}
value := []int64{2 * 1e9, 3 * 1e9, 4 * 1e9}
cfg.NodeRpc = "http://testnet-rpc.xdagj.org:10001"
payouts.Cfg = &cfg
iLogFile := "logs/info.log"
eLogFile := "logs/error.log"
sLogFile := "logs/share.log"
bLogFile := "logs/block.log"
util.InitLog(iLogFile, eLogFile, sLogFile, bLogFile, 10)
wallet := bip.NewWallet(path.Join(".", common.BIP32_WALLET_FOLDER, common.BIP32_WALLET_FILE_NAME))
res := wallet.UnlockWallet("111")
if res && wallet.IsHdWalletInitialized() {
// fmt.Println(wallet.GetMnemonic())
key := wallet.GetDefKey()
hash, err := payouts.TransferChunkRpc(value, "Fii9BuhR1KogfNzWbtSH1YJgQQDwFMomK", to, "hello", key)
fmt.Println(hash)
fmt.Println(err)
}
}
func TestPayChunk(t *testing.T) {
to := []string{"4duPWMbYUgAifVYkKDCWxLvRRkSByf5gb", "Fve2AF8NrEPjNcAj5BABTBeqn7LW7WfeT", "Fii9BuhR1KogfNzWbtSH1YJgQQDwFMomK"}
value := []int64{2 * 1e9, 3 * 1e9, 4 * 1e9}
cfg.NodeRpc = "http://testnet-rpc.xdagj.org:10001"
cfg.Coin = "xdag"
cfg.KvRocks = pool.StorageConfig{
Endpoint: "127.0.0.1:6379",
PasswordEncrypted: "MbRmWtAs7GA2E1B6ioBSoQ==",
Password: "123456",
Database: 0,
PoolSize: 10,
}
cfg.Address = "Dd2KRkRceHtx7ep3qWHVAHEdjYoyPpAYx"
payouts.Cfg = &cfg
iLogFile := "logs/info.log"
eLogFile := "logs/error.log"
sLogFile := "logs/share.log"
bLogFile := "logs/block.log"
util.InitLog(iLogFile, eLogFile, sLogFile, bLogFile, 10)
wallet := bip.NewWallet(path.Join(".", common.BIP32_WALLET_FOLDER, common.BIP32_WALLET_FILE_NAME))
res := wallet.UnlockWallet("111")
if res && wallet.IsHdWalletInitialized() {
payouts.BipKey = wallet.GetDefKey()
backend = kvstore.NewKvClient(&cfg.KvRocks, cfg.Coin)
payouts.PayChunk(backend, &to, &value, "test pay")
}
}