Upgrade github.com/gagliardetto/binary to v0.5.1
This commit is contained in:
parent
1ff3e1e5ec
commit
73311b0b87
2
go.mod
2
go.mod
|
@ -17,7 +17,7 @@ require (
|
|||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/dfuse-io/logging v0.0.0-20210109005628-b97a57253f70
|
||||
github.com/fatih/color v1.7.0
|
||||
github.com/gagliardetto/binary v0.5.0
|
||||
github.com/gagliardetto/binary v0.5.1
|
||||
github.com/gagliardetto/gofuzz v1.2.2
|
||||
github.com/gagliardetto/treeout v0.1.4
|
||||
github.com/google/go-cmp v0.5.1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -89,8 +89,8 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
|||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gagliardetto/binary v0.5.0 h1:fLVIbMEQp5zbW0SFtg0z/WHy2iUw/SMeuakzfa5ayhI=
|
||||
github.com/gagliardetto/binary v0.5.0/go.mod h1:peJR9PvwamL4YOh1nHWCPLry2VEfeeD1ADvewka7HnQ=
|
||||
github.com/gagliardetto/binary v0.5.1 h1:iNEy3p7r/DK352CRO7pp+3zNITGZKk8hwkH3BpaGFeo=
|
||||
github.com/gagliardetto/binary v0.5.1/go.mod h1:peJR9PvwamL4YOh1nHWCPLry2VEfeeD1ADvewka7HnQ=
|
||||
github.com/gagliardetto/gofuzz v1.2.2 h1:XL/8qDMzcgvR4+CyRQW9UGdwPRPMHVJfqQ/uMvSUuQw=
|
||||
github.com/gagliardetto/gofuzz v1.2.2/go.mod h1:bkH/3hYLZrMLbfYWA0pWzXmi5TTRZnu4pMGZBkqMKvY=
|
||||
github.com/gagliardetto/treeout v0.1.4 h1:ozeYerrLCmCubo1TcIjFiOWTTGteOOHND1twdFpgwaw=
|
||||
|
|
|
@ -177,11 +177,7 @@ func (inst AllocateWithSeed) MarshalWithEncoder(encoder *ag_binary.Encoder) erro
|
|||
}
|
||||
// Serialize `Seed` param:
|
||||
{
|
||||
err := encoder.WriteUint64(uint64(len(*inst.Seed)), binary.LittleEndian)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = encoder.WriteBytes([]byte(*inst.Seed), false)
|
||||
err := encoder.WriteRustString(*inst.Seed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -213,15 +209,10 @@ func (inst *AllocateWithSeed) UnmarshalWithDecoder(decoder *ag_binary.Decoder) e
|
|||
}
|
||||
// Deserialize `Seed` param:
|
||||
{
|
||||
length, err := decoder.ReadUint64(binary.LittleEndian)
|
||||
value, err := decoder.ReadRustString()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bytes, err := decoder.ReadNBytes(int(length))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value := string(bytes)
|
||||
inst.Seed = &value
|
||||
}
|
||||
// Deserialize `Space` param:
|
||||
|
|
|
@ -164,11 +164,7 @@ func (inst AssignWithSeed) MarshalWithEncoder(encoder *ag_binary.Encoder) error
|
|||
}
|
||||
// Serialize `Seed` param:
|
||||
{
|
||||
err := encoder.WriteUint64(uint64(len(*inst.Seed)), binary.LittleEndian)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = encoder.WriteBytes([]byte(*inst.Seed), false)
|
||||
err := encoder.WriteRustString(*inst.Seed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -193,15 +189,10 @@ func (inst *AssignWithSeed) UnmarshalWithDecoder(decoder *ag_binary.Decoder) err
|
|||
}
|
||||
// Deserialize `Seed` param:
|
||||
{
|
||||
length, err := decoder.ReadUint64(binary.LittleEndian)
|
||||
value, err := decoder.ReadRustString()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bytes, err := decoder.ReadNBytes(int(length))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value := string(bytes)
|
||||
inst.Seed = &value
|
||||
}
|
||||
// Deserialize `Owner` param:
|
||||
|
|
|
@ -212,11 +212,7 @@ func (inst CreateAccountWithSeed) MarshalWithEncoder(encoder *ag_binary.Encoder)
|
|||
}
|
||||
// Serialize `Seed` param:
|
||||
{
|
||||
err := encoder.WriteUint64(uint64(len(*inst.Seed)), binary.LittleEndian)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = encoder.WriteBytes([]byte(*inst.Seed), false)
|
||||
err := encoder.WriteRustString(*inst.Seed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -255,15 +251,10 @@ func (inst *CreateAccountWithSeed) UnmarshalWithDecoder(decoder *ag_binary.Decod
|
|||
}
|
||||
// Deserialize `Seed` param:
|
||||
{
|
||||
length, err := decoder.ReadUint64(binary.LittleEndian)
|
||||
value, err := decoder.ReadRustString()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bytes, err := decoder.ReadNBytes(int(length))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value := string(bytes)
|
||||
inst.Seed = &value
|
||||
}
|
||||
// Deserialize `Lamports` param:
|
||||
|
|
|
@ -178,11 +178,7 @@ func (inst TransferWithSeed) MarshalWithEncoder(encoder *ag_binary.Encoder) erro
|
|||
}
|
||||
// Serialize `FromSeed` param:
|
||||
{
|
||||
err := encoder.WriteUint64(uint64(len(*inst.FromSeed)), binary.LittleEndian)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = encoder.WriteBytes([]byte(*inst.FromSeed), false)
|
||||
err := encoder.WriteRustString(*inst.FromSeed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -207,15 +203,10 @@ func (inst *TransferWithSeed) UnmarshalWithDecoder(decoder *ag_binary.Decoder) e
|
|||
}
|
||||
// Deserialize `FromSeed` param:
|
||||
{
|
||||
length, err := decoder.ReadUint64(binary.LittleEndian)
|
||||
value, err := decoder.ReadRustString()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bytes, err := decoder.ReadNBytes(int(length))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value := string(bytes)
|
||||
inst.FromSeed = &value
|
||||
}
|
||||
// Deserialize `FromOwner` param:
|
||||
|
|
|
@ -4,19 +4,28 @@ import (
|
|||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
bin "github.com/gagliardetto/binary"
|
||||
"github.com/gagliardetto/solana-go"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMint(t *testing.T) {
|
||||
account := []byte{1, 0, 0, 0, 5, 234, 156, 241, 108, 228, 17, 152, 241, 164, 153, 55, 200, 140, 55, 10, 148, 212, 175, 255, 137, 181, 186, 203, 142, 244, 94, 99, 36, 187, 120, 247, 9, 169, 49, 235, 241, 182, 6, 0, 6, 1, 1, 0, 0, 0, 5, 234, 156, 241, 108, 228, 17, 152, 241, 164, 153, 55, 200, 140, 55, 10, 148, 212, 175, 255, 137, 181, 186, 203, 142, 244, 94, 99, 36, 187, 120, 247}
|
||||
account := []byte{
|
||||
1, 0, 0, 0,
|
||||
5, 234, 156, 241, 108, 228, 17, 152, 241, 164, 153, 55, 200, 140, 55, 10, 148, 212, 175, 255, 137, 181, 186, 203, 142, 244, 94, 99, 36, 187, 120, 247,
|
||||
9, 169, 49, 235, 241, 182, 6, 0,
|
||||
6,
|
||||
1,
|
||||
1, 0, 0, 0,
|
||||
5, 234, 156, 241, 108, 228, 17, 152, 241, 164, 153, 55, 200, 140, 55, 10, 148, 212, 175, 255, 137, 181, 186, 203, 142, 244, 94, 99, 36, 187, 120, 247,
|
||||
}
|
||||
{
|
||||
dec := bin.NewBorshDecoder(account)
|
||||
mint := new(Mint)
|
||||
dec := bin.NewBinDecoder(account)
|
||||
mint := Mint{}
|
||||
|
||||
err := mint.UnmarshalWithDecoder(dec)
|
||||
require.NoError(t, err)
|
||||
err := dec.Decode(&mint)
|
||||
require.NoError(t, err, spew.Sdump(mint))
|
||||
|
||||
require.Equal(t,
|
||||
&Mint{
|
||||
|
@ -26,12 +35,12 @@ func TestMint(t *testing.T) {
|
|||
IsInitialized: true,
|
||||
FreezeAuthority: solana.MustPublicKeyFromBase58("Q6XprfkF8RQQKoQVG33xT88H7wi8Uk1B1CC7YAs69Gi").ToPointer(),
|
||||
},
|
||||
mint,
|
||||
&mint,
|
||||
)
|
||||
|
||||
{
|
||||
buf := new(bytes.Buffer)
|
||||
err := mint.MarshalWithEncoder(bin.NewBinEncoder(buf))
|
||||
err := bin.NewBinEncoder(buf).Encode(mint)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, account, buf.Bytes())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue