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>
This commit is contained in:
Jonathan Claudius 2022-02-21 17:23:34 -05:00 committed by GitHub
parent 885754e723
commit d47089741c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

View File

@ -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)
}