github.com/aeternity/aepp-sdk-go/v4@v4.0.1/cmd/tx_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/aeternity/aepp-sdk-go/aeternity"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  var alice = "ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi"
    11  var bob = "ak_Egp9yVdpxmvAfQ7vsXGvpnyfNq71msbdUpkMNYGTeTe8kPL3v"
    12  
    13  func TestTxSpend(t *testing.T) {
    14  	emptyCmd := cobra.Command{}
    15  
    16  	err := txSpendFunc(&emptyCmd, []string{alice, bob, "10"})
    17  	if err != nil {
    18  		t.Error(err)
    19  	}
    20  }
    21  
    22  func TestTxVerify(t *testing.T) {
    23  	// unsigned tx_+FMMAaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vOhAR8To7CL8AFABmKmi2nYdfeAPOxMCGR/btXYTHiXvVCjCoa15iD0gACCAfQBgIHqJ/Y=
    24  	// sign with ae_mainnet
    25  	signedTx := "tx_+J0LAfhCuEBcvwtyCo3FYqmINcP6lHLH/dRDcj5rUiKDqYKhPpiQ+1SBQ66rF3gdVQ1IcANcw/IayK//YgK2dsDF1VtroQEAuFX4UwwBoQHOp63kcMn5nZ1OQAiAqG8dSbtES2LxGp67ZLvP63P+86EBHxOjsIvwAUAGYqaLadh194A87EwIZH9u1dhMeJe9UKMKhrXmIPSAAIIB9AGAx+EjLg=="
    26  	aeternity.Config.Node.NetworkID = "ae_mainnet"
    27  	emptyCmd := cobra.Command{}
    28  
    29  	err := txVerifyFunc(&emptyCmd, []string{alice, signedTx})
    30  	if err != nil {
    31  		t.Error(err)
    32  	}
    33  }
    34  
    35  func TestTxDumpRaw(t *testing.T) {
    36  	tx := "tx_+H4iAaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vMFoQJei0cGdDWb3EfrY0mtZADF0LoQ4yL6z10I/3ETJ0fpKADy8Y5hY2NvdW50X3B1YmtleaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vMGAQXLBNnv"
    37  	emptyCmd := cobra.Command{}
    38  
    39  	err := txDumpRawFunc(&emptyCmd, []string{tx})
    40  	if err != nil {
    41  		t.Error(err)
    42  	}
    43  }
    44  
    45  func Test_txContractCreateFunc(t *testing.T) {
    46  	type args struct {
    47  		cmd  *cobra.Command
    48  		args []string
    49  	}
    50  	tests := []struct {
    51  		name    string
    52  		args    args
    53  		wantErr bool
    54  	}{
    55  		{
    56  			name: "Deploy SimpleStorage with alice (unsigned)",
    57  			args: args{
    58  				cmd:  &cobra.Command{},
    59  				args: []string{alice, contractSimpleStorageBytecode, contractSimpleStorageInitCalldata},
    60  			},
    61  			wantErr: false,
    62  		},
    63  	}
    64  	for _, tt := range tests {
    65  		t.Run(tt.name, func(t *testing.T) {
    66  			if err := txContractCreateFunc(tt.args.cmd, tt.args.args); (err != nil) != tt.wantErr {
    67  				t.Errorf("txContractCreateFunc() error = %v, wantErr %v", err, tt.wantErr)
    68  			}
    69  		})
    70  	}
    71  }