Add governance VAA initializer
Change-Id: I4c5a050e5b17ed8b278f91e26bf61adacc45ecc5
This commit is contained in:
parent
6bbc1f7ad4
commit
b01ad107e7
|
@ -0,0 +1,25 @@
|
||||||
|
package vaa
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
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}
|
||||||
|
var governanceChain = ChainIDSolana
|
||||||
|
|
||||||
|
func CreateGovernanceVAA(nonce uint32, sequence uint64, guardianSetIndex uint32, payload []byte) *VAA {
|
||||||
|
vaa := &VAA{
|
||||||
|
Version: 1,
|
||||||
|
GuardianSetIndex: guardianSetIndex,
|
||||||
|
Signatures: nil,
|
||||||
|
Timestamp: time.Unix(0, 0),
|
||||||
|
Nonce: nonce,
|
||||||
|
Sequence: sequence,
|
||||||
|
ConsistencyLevel: 32,
|
||||||
|
EmitterChain: governanceChain,
|
||||||
|
EmitterAddress: governanceEmitter,
|
||||||
|
Payload: payload,
|
||||||
|
}
|
||||||
|
|
||||||
|
return vaa
|
||||||
|
}
|
|
@ -101,3 +101,12 @@ func TestBodyRegisterChain_Serialize(t *testing.T) {
|
||||||
data := msg.Serialize()
|
data := msg.Serialize()
|
||||||
require.Equal(t, "000000000000000000000000000000000000000000546f6b656e42726964676501000000080102030400000000000000000000000000000000000000000000000000000000", hex.EncodeToString(data))
|
require.Equal(t, "000000000000000000000000000000000000000000546f6b656e42726964676501000000080102030400000000000000000000000000000000000000000000000000000000", hex.EncodeToString(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBodyRegisterChain_Serializee(t *testing.T) {
|
||||||
|
payload, _ := hex.DecodeString("000000000000000000000000000000000000000000546f6b656e42726964676501000000080102030400000000000000000000000000000000000000000000000000000000")
|
||||||
|
key, _ := crypto.HexToECDSA("cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0")
|
||||||
|
vaa := CreateGovernanceVAA(12, 38, 1, payload)
|
||||||
|
vaa.AddSignature(key, 0)
|
||||||
|
vaaData, _ := vaa.Marshal()
|
||||||
|
require.Equal(t, "01000000010100c764f98742e6dce38580d0502d60b16404336148cf7364c07ee4bb96a1b2b8072c36ae911f0896e505dbb5b543ca338b3867cdabb5579e5f0c5f5d575f12da0700000000000000000c00010000000000000000000000000000000000000000000000000000000000000004000000000000002620000000000000000000000000000000000000000000546f6b656e42726964676501000000080102030400000000000000000000000000000000000000000000000000000000", hex.EncodeToString(vaaData))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue