Skip to content

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Dharitri-org committed Mar 21, 2024
1 parent 7ce80af commit c938087
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 139 deletions.
3 changes: 3 additions & 0 deletions builtInFunctions/setGuardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (sg *setGuardian) ProcessBuiltinFunction(
if vmInput == nil {
return nil, ErrNilVmInput
}
if len(vmInput.Arguments) != noOfArgsSetGuardian {
return nil, fmt.Errorf("%w, expected %d, got %d ", ErrInvalidNumberOfArguments, noOfArgsSetGuardian, len(vmInput.Arguments))
}

senderAddr := acntSnd.AddressBytes()
senderIsNotCaller := !bytes.Equal(senderAddr, vmInput.CallerAddr)
Expand Down
22 changes: 22 additions & 0 deletions builtInFunctions/setGuardian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ func TestSetGuardian_ProcessBuiltinFunctionCheckArguments(t *testing.T) {
receiverAccount: account,
expectedErr: ErrNilVmInput,
},
{
testname: "nil vm input arguments should error",
vmInput: func() *vmcommon.ContractCallInput {
input := *vmInput
input.Arguments = nil
return &input
},
senderAccount: account,
receiverAccount: account,
expectedErr: ErrInvalidNumberOfArguments,
},
{
testname: "one input arguments should error",
vmInput: func() *vmcommon.ContractCallInput {
input := *vmInput
input.Arguments = [][]byte{guardianAddress}
return &input
},
senderAccount: account,
receiverAccount: account,
expectedErr: ErrInvalidNumberOfArguments,
},
{
testname: "sender different to caller should error",
vmInput: func() *vmcommon.ContractCallInput {
Expand Down
Loading

0 comments on commit c938087

Please sign in to comment.