OSDN Git Service

modify test
authormars <mars@bytom.io>
Thu, 25 Jul 2019 07:38:32 +0000 (15:38 +0800)
committermars <mars@bytom.io>
Thu, 25 Jul 2019 07:38:32 +0000 (15:38 +0800)
consensus/general.go
toolbar/apinode/node_test.go
toolbar/common/consensus.go

index f3bab4e..d0e89a1 100644 (file)
@@ -188,7 +188,7 @@ var SoloNetParams = Params{
                CoinbaseArbitrarySizeLimit: 128,
        },
        DPOSConfig: DPOSConfig{
-               NumOfConsensusNode:      10,
+               NumOfConsensusNode:      1,
                BlockNumEachNode:        12,
                MinConsensusNodeVoteNum: uint64(100000000000000),
                MinVoteOutputAmount:     uint64(100000000),
index 681bf02..78bae8f 100644 (file)
@@ -39,22 +39,22 @@ type args struct {
 
 func TestBuildTxRequest(t *testing.T) {
        cases := []struct {
-               args args
-               want string
+               args  args
+               wants []string
        }{
                {
                        args: args{
                                accountID: "9bb77612-350e-4d53-81e2-525b28247ba5",
                                outputs:   map[string]uint64{"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf": 100},
                        },
-                       want: `{"actions":[{"type":"control_address","address":"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":100},{"type":"spend_account","account_id":"9bb77612-350e-4d53-81e2-525b28247ba5","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":10000100}]}`,
+                       wants: []string{`{"actions":[{"type":"control_address","address":"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":100},{"type":"spend_account","account_id":"9bb77612-350e-4d53-81e2-525b28247ba5","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":10000100}]}`},
                },
                {
                        args: args{
                                accountID: "9bb77612-350e-4d53-81e2-525b28247ba5",
                                outputs:   map[string]uint64{"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf": 100, "sp1qcgtxkhfzytul4lfttwex3skfqhm0tg6ms9da28": 200},
                        },
-                       want: `{"actions":[{"type":"control_address","address":"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":100},{"type":"control_address","address":"sp1qcgtxkhfzytul4lfttwex3skfqhm0tg6ms9da28","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":200},{"type":"spend_account","account_id":"9bb77612-350e-4d53-81e2-525b28247ba5","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":10000300}]}`,
+                       wants: []string{`{"actions":[{"type":"control_address","address":"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":100},{"type":"control_address","address":"sp1qcgtxkhfzytul4lfttwex3skfqhm0tg6ms9da28","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":200},{"type":"spend_account","account_id":"9bb77612-350e-4d53-81e2-525b28247ba5","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":10000300}]}`, `{"actions":[{"type":"control_address","address":"sp1qcgtxkhfzytul4lfttwex3skfqhm0tg6ms9da28","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":200},{"type":"control_address","address":"sp1qlryy65a5apylphqp6axvhx7nd6y2zlexuvn7gf","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":100},{"type":"spend_account","account_id":"9bb77612-350e-4d53-81e2-525b28247ba5","asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","amount":10000300}]}`},
                },
        }
 
@@ -63,7 +63,13 @@ func TestBuildTxRequest(t *testing.T) {
                if err != nil {
                        t.Fatal(err)
                }
-               if string(tx) != string(c.want) {
+               num := 0
+               for _, want := range c.wants {
+                       if string(tx) == string(want) {
+                               num++
+                       }
+               }
+               if num != 1 {
                        t.Fatal(i, string(tx))
                }
        }
index 50983b1..50dab9f 100644 (file)
@@ -7,7 +7,7 @@ import (
        "github.com/vapor/consensus"
 )
 
-const NumOfBPNode = 42
+const NumOfBPNode = 33
 
 func CalcStandByNodes(voteResult []*api.VoteInfo) []*api.VoteInfo {
        sort.Slice(voteResult, func(i, j int) bool {