-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsendoutputs_test.go
74 lines (66 loc) · 2.2 KB
/
sendoutputs_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
package pfcregtest
import (
"github.com/picfight/pfcd/wire"
"github.com/jfixby/coinharness"
"github.com/picfight/pfcharness"
"github.com/jfixby/pin"
"testing"
)
func TestBallance(t *testing.T) {
// Skip tests when running with -short
//if testing.Short() {
// t.Skip("Skipping RPC harness tests in short mode")
//}
r := ObtainHarness(t.Name() + ".8")
expectedBalance := coinharness.CoinsAmountFromFloat(7200)
actualBalance := coinharness.GetBalance(t, r.Wallet).Balances[coinharness.DefaultAccountName].Spendable
if actualBalance.AtomsValue != expectedBalance.AtomsValue {
t.Fatalf("expected wallet balance of %v instead have %v",
expectedBalance, actualBalance)
}
}
func TestSendOutputs(t *testing.T) {
// Skip tests when running with -short
//if testing.Short() {
// t.Skip("Skipping RPC harness tests in short mode")
//}
r := ObtainHarness("TestSendOutputs")
_, H, e := r.NodeRPCClient().GetBestBlock()
pin.CheckTestSetupMalfunction(e)
r.Wallet.Sync(H)
// First, generate a small spend which will require only a single
// input.
txid := coinharness.GenSpend(t, r,
coinharness.DefaultAccountName,
coinharness.CoinsAmountFromFloat(5),
wire.DefaultPkScriptVersion,
pfcharness.PayToAddrScript,
pfcharness.TxSerializeSize,
)
// Generate a single block, the transaction the wallet created should
// be found in this block.
blockHashes, err := r.NodeRPCClient().Generate(1)
if err != nil {
t.Fatalf("unable to generate single block: %v", err)
}
coinharness.AssertTxMined(t, r, txid, blockHashes[0])
// Next, generate a spend much greater than the block reward. This
// transaction should also have been mined properly.
txid = coinharness.GenSpend(t, r,
coinharness.DefaultAccountName,
coinharness.CoinsAmountFromFloat(1000),
wire.DefaultPkScriptVersion,
pfcharness.PayToAddrScript,
pfcharness.TxSerializeSize,
)
blockHashes, err = r.NodeRPCClient().Generate(1)
if err != nil {
t.Fatalf("unable to generate single block: %v", err)
}
coinharness.AssertTxMined(t, r, txid, blockHashes[0])
// Generate another block to ensure the transaction is removed from the
// mempool.
if _, err := r.NodeRPCClient().Generate(1); err != nil {
t.Fatalf("unable to generate block: %v", err)
}
}