linter fixes

This commit is contained in:
Mike Seiler 2023-01-17 16:53:28 +00:00
parent b49c455df0
commit 2a95648625
2 changed files with 7 additions and 7 deletions

View File

@ -17,15 +17,15 @@ import (
"github.com/filecoin-project/lotus/itests/kit" "github.com/filecoin-project/lotus/itests/kit"
) )
//convert a simple byte array into input data which is a left padded 32 byte array // convert a simple byte array into input data which is a left padded 32 byte array
func inputDataFromArray(input []byte) []byte { func inputDataFromArray(input []byte) []byte {
inputData := make([]byte, 32) inputData := make([]byte, 32)
copy(inputData[32-len(input):], input[:]) copy(inputData[32-len(input):], input[:])
return inputData return inputData
} }
//convert a "from" address into input data which is a left padded 32 byte array // convert a "from" address into input data which is a left padded 32 byte array
func inputDataFromFrom(t *testing.T, ctx context.Context, client *kit.TestFullNode, from address.Address) []byte { func inputDataFromFrom(ctx context.Context, t *testing.T, client *kit.TestFullNode, from address.Address) []byte {
fromId, err := client.StateLookupID(ctx, from, types.EmptyTSK) fromId, err := client.StateLookupID(ctx, from, types.EmptyTSK)
require.NoError(t, err) require.NoError(t, err)
@ -57,7 +57,7 @@ func TestFEVMBasic(t *testing.T) {
// invoke the contract with owner // invoke the contract with owner
{ {
inputData := inputDataFromFrom(t, ctx, client, fromAddr) inputData := inputDataFromFrom(ctx, t, client, fromAddr)
result := client.EVM().InvokeContractByFuncName(ctx, fromAddr, idAddr, "getBalance(address)", inputData) result := client.EVM().InvokeContractByFuncName(ctx, fromAddr, idAddr, "getBalance(address)", inputData)
expectedResult, err := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000002710") expectedResult, err := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000002710")
@ -67,7 +67,7 @@ func TestFEVMBasic(t *testing.T) {
// invoke the contract with non owner // invoke the contract with non owner
{ {
inputData := inputDataFromFrom(t, ctx, client, fromAddr) inputData := inputDataFromFrom(ctx, t, client, fromAddr)
inputData[31]++ // change the pub address to one that has 0 balance by incrementing the last byte of the address inputData[31]++ // change the pub address to one that has 0 balance by incrementing the last byte of the address
result := client.EVM().InvokeContractByFuncName(ctx, fromAddr, idAddr, "getBalance(address)", inputData) result := client.EVM().InvokeContractByFuncName(ctx, fromAddr, idAddr, "getBalance(address)", inputData)
@ -112,7 +112,7 @@ func TestFEVMDelegateCall(t *testing.T) {
//call Contract Storage which makes a delegatecall to contract Actor //call Contract Storage which makes a delegatecall to contract Actor
//this contract call sets the "counter" variable to 7, from default value 0 //this contract call sets the "counter" variable to 7, from default value 0
inputDataContract := inputDataFromFrom(t, ctx, client, actorAddr) inputDataContract := inputDataFromFrom(ctx, t, client, actorAddr)
inputDataValue := inputDataFromArray([]byte{7}) inputDataValue := inputDataFromArray([]byte{7})
inputData := append(inputDataContract, inputDataValue...) inputData := append(inputDataContract, inputDataValue...)

View File

@ -241,7 +241,7 @@ func (e *EVM) InvokeContractByFuncName(ctx context.Context, fromAddr address.Add
return result return result
} }
//function signatures are the first 4 bytes of the hash of the function name and types // function signatures are the first 4 bytes of the hash of the function name and types
func CalcFuncSignature(funcName string) []byte { func CalcFuncSignature(funcName string) []byte {
hasher := sha3.NewLegacyKeccak256() hasher := sha3.NewLegacyKeccak256()
hasher.Write([]byte(funcName)) hasher.Write([]byte(funcName))