aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/test/utils.go')
-rw-r--r--core/test/utils.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/test/utils.go b/core/test/utils.go
index da76860..f5f4c36 100644
--- a/core/test/utils.go
+++ b/core/test/utils.go
@@ -27,6 +27,8 @@ import (
"github.com/dexon-foundation/dexon-consensus/core/crypto"
"github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa"
"github.com/dexon-foundation/dexon-consensus/core/types"
+ typesDKG "github.com/dexon-foundation/dexon-consensus/core/types/dkg"
+ "github.com/dexon-foundation/dexon/rlp"
)
func stableRandomHash(block *types.Block) (common.Hash, error) {
@@ -116,3 +118,42 @@ func NewKeys(count int) (
}
return
}
+
+func cloneDKGComplaint(
+ comp *typesDKG.Complaint) (copied *typesDKG.Complaint) {
+ b, err := rlp.EncodeToBytes(comp)
+ if err != nil {
+ panic(err)
+ }
+ copied = &typesDKG.Complaint{}
+ if err = rlp.DecodeBytes(b, copied); err != nil {
+ panic(err)
+ }
+ return
+}
+
+func cloneDKGMasterPublicKey(mpk *typesDKG.MasterPublicKey) (
+ copied *typesDKG.MasterPublicKey) {
+ b, err := rlp.EncodeToBytes(mpk)
+ if err != nil {
+ panic(err)
+ }
+ copied = typesDKG.NewMasterPublicKey()
+ if err = rlp.DecodeBytes(b, copied); err != nil {
+ panic(err)
+ }
+ return
+}
+
+func cloneDKGFinalize(final *typesDKG.Finalize) (
+ copied *typesDKG.Finalize) {
+ b, err := rlp.EncodeToBytes(final)
+ if err != nil {
+ panic(err)
+ }
+ copied = &typesDKG.Finalize{}
+ if err = rlp.DecodeBytes(b, copied); err != nil {
+ panic(err)
+ }
+ return
+}