governance_test.go 948 B

1234567891011121314151617181920212223242526272829303132333435
  1. package vaa
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. // Testing the expected default behavior of a CreateGovernanceVAA
  8. func TestCreateGovernanceVAA(t *testing.T) {
  9. var nonce uint32 = 1
  10. var sequence uint64 = 1
  11. var guardianSetIndex uint32 = 1
  12. var payload = []byte{97, 97, 97, 97, 97, 97}
  13. var timestamp = time.Unix(1000, 0)
  14. 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}
  15. got_vaa := CreateGovernanceVAA(timestamp, nonce, sequence, guardianSetIndex, payload)
  16. want_vaa := &VAA{
  17. Version: uint8(1),
  18. GuardianSetIndex: uint32(1),
  19. Signatures: nil,
  20. Timestamp: timestamp,
  21. Nonce: uint32(1),
  22. Sequence: uint64(1),
  23. ConsistencyLevel: uint8(32),
  24. EmitterChain: ChainIDSolana,
  25. EmitterAddress: governanceEmitter,
  26. Payload: payload,
  27. }
  28. assert.Equal(t, got_vaa, want_vaa)
  29. }