github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/deploy/def/jobs_test.go (about)

     1  package def
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hyperledger/burrow/acm"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestGovernAccount_Validate(t *testing.T) {
    12  	sourceAddress := acm.GeneratePrivateAccountFromSecret("frogs").GetAddress()
    13  	targetAddress := acm.GeneratePrivateAccountFromSecret("logs").GetAddress()
    14  	job := &UpdateAccount{
    15  		Target:      targetAddress.String(),
    16  		Source:      sourceAddress.String(),
    17  		Sequence:    "34",
    18  		Native:      "1033",
    19  		Power:       "324324322",
    20  		Roles:       []string{"foo"},
    21  		Permissions: []PermissionString{"root", "send"},
    22  	}
    23  	err := job.Validate()
    24  	require.NoError(t, err)
    25  }
    26  
    27  func TestKeyNameCurveType(t *testing.T) {
    28  	match := NewKeyRegex.FindStringSubmatch("new()")
    29  	keyName, curveType := KeyNameCurveType(match)
    30  	assert.Equal(t, "", keyName)
    31  	assert.Equal(t, "", curveType)
    32  
    33  	match = NewKeyRegex.FindStringSubmatch("new(mySpecialKey)")
    34  	keyName, curveType = KeyNameCurveType(match)
    35  	assert.Equal(t, "mySpecialKey", keyName)
    36  	assert.Equal(t, "", curveType)
    37  
    38  	match = NewKeyRegex.FindStringSubmatch("new(,secp256k1)")
    39  	keyName, curveType = KeyNameCurveType(match)
    40  	assert.Equal(t, "", keyName)
    41  	assert.Equal(t, "secp256k1", curveType)
    42  
    43  	match = NewKeyRegex.FindStringSubmatch("new(myLessSpecialKey0,ed25519)")
    44  	keyName, curveType = KeyNameCurveType(match)
    45  	assert.Equal(t, "myLessSpecialKey0", keyName)
    46  	assert.Equal(t, "ed25519", curveType)
    47  
    48  	assert.False(t, NewKeyRegex.MatchString("new"))
    49  }