github.com/MetalBlockchain/subnet-evm@v0.4.9/precompile/utils_test.go (about)

     1  // (c) 2019-2020, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package precompile
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestFunctionSignatureRegex(t *testing.T) {
    13  	type test struct {
    14  		str  string
    15  		pass bool
    16  	}
    17  
    18  	for _, test := range []test{
    19  		{
    20  			str:  "getBalance()",
    21  			pass: true,
    22  		},
    23  		{
    24  			str:  "getBalance(address)",
    25  			pass: true,
    26  		},
    27  		{
    28  			str:  "getBalance(address,address)",
    29  			pass: true,
    30  		},
    31  		{
    32  			str:  "getBalance(address,address,address)",
    33  			pass: true,
    34  		},
    35  		{
    36  			str:  "getBalance(address,address,address,uint256)",
    37  			pass: true,
    38  		},
    39  		{
    40  			str:  "getBalance(address,)",
    41  			pass: false,
    42  		},
    43  		{
    44  			str:  "getBalance(address,address,)",
    45  			pass: false,
    46  		},
    47  		{
    48  			str:  "getBalance(,)",
    49  			pass: false,
    50  		},
    51  		{
    52  			str:  "(address,)",
    53  			pass: false,
    54  		},
    55  		{
    56  			str:  "()",
    57  			pass: false,
    58  		},
    59  		{
    60  			str:  "dummy",
    61  			pass: false,
    62  		},
    63  	} {
    64  		assert.Equal(t, test.pass, functionSignatureRegex.MatchString(test.str), "unexpected result for %q", test.str)
    65  	}
    66  }