Procházet zdrojové kódy

Add unit-test for governance (#867)

* Add unit-test for governance

* Gofmt governance_test.go

* Use structs for testing governance VAA

Co-authored-by: claudijd <jclaudius@jumptrading.com>
Jonathan Claudius před 3 roky
rodič
revize
d47089741c
1 změnil soubory, kde provedl 31 přidání a 0 odebrání
  1. 31 0
      node/pkg/vaa/governance_test.go

+ 31 - 0
node/pkg/vaa/governance_test.go

@@ -0,0 +1,31 @@
+package vaa
+
+import "testing"
+import "time"
+import "github.com/stretchr/testify/assert"
+
+// Testing the expected default behavior of a CreateGovernanceVAA
+func TestCreateGovernanceVAA(t *testing.T) {
+	var nonce uint32 = 1
+	var sequence uint64 = 1
+	var guardianSetIndex uint32 = 1
+	var payload = []byte{97, 97, 97, 97, 97, 97}
+	var governanceEmitter = Address{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}
+
+	got_vaa := CreateGovernanceVAA(nonce, sequence, guardianSetIndex, payload)
+	
+	want_vaa := &VAA{
+		Version:          uint8(1),
+		GuardianSetIndex: uint32(1),
+		Signatures:       nil,
+		Timestamp:        time.Unix(0, 0),
+		Nonce:            uint32(1),
+		Sequence:         uint64(1),
+		ConsistencyLevel: uint8(32),
+		EmitterChain:     ChainIDSolana,
+		EmitterAddress:   governanceEmitter,
+		Payload:          payload,
+	}
+
+	assert.Equal(t, got_vaa, want_vaa)
+}