github.com/gagliardetto/solana-go@v1.11.0/programs/system/Allocate_test.go (about)

     1  // Copyright 2021 github.com/gagliardetto
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package system
    16  
    17  import (
    18  	"bytes"
    19  	"strconv"
    20  	"testing"
    21  
    22  	ag_gofuzz "github.com/gagliardetto/gofuzz"
    23  	ag_require "github.com/stretchr/testify/require"
    24  )
    25  
    26  func TestEncodeDecode_Allocate(t *testing.T) {
    27  	fu := ag_gofuzz.New().NilChance(0)
    28  	for i := 0; i < 1; i++ {
    29  		t.Run("Allocate"+strconv.Itoa(i), func(t *testing.T) {
    30  			{
    31  				params := new(Allocate)
    32  				fu.Fuzz(params)
    33  				params.AccountMetaSlice = nil
    34  				buf := new(bytes.Buffer)
    35  				err := encodeT(*params, buf)
    36  				ag_require.NoError(t, err)
    37  				//
    38  				got := new(Allocate)
    39  				err = decodeT(got, buf.Bytes())
    40  				got.AccountMetaSlice = nil
    41  				ag_require.NoError(t, err)
    42  				ag_require.Equal(t, params, got)
    43  			}
    44  		})
    45  	}
    46  }