Skip to content

Commit

Permalink
test: increase max transaction fee for default test client
Browse files Browse the repository at this point in the history
  • Loading branch information
janaakhterov committed Dec 22, 2020
1 parent 1a21382 commit 566ccb1
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 117 deletions.
44 changes: 0 additions & 44 deletions contract_create_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,47 +206,3 @@ func Test_ContractCreate_NoBytecodeFileID(t *testing.T) {
_, err = resp.GetReceipt(client)
assert.NoError(t, err)
}

func Test_ContractCreateTransaction_NoMaxFee(t *testing.T) {
// Note: this is the bytecode for the contract found in the example for ./examples/create_simple_contract
testContractByteCode := []byte(`608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101cb806100606000396000f3fe608060405260043610610046576000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b51461004b578063cfae321714610062575b600080fd5b34801561005757600080fd5b506100606100f2565b005b34801561006e57600080fd5b50610077610162565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b757808201518184015260208101905061009c565b50505050905090810190601f1680156100e45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610160573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b60606040805190810160405280600d81526020017f48656c6c6f2c20776f726c64210000000000000000000000000000000000000081525090509056fea165627a7a72305820ae96fb3af7cde9c0abfe365272441894ab717f816f07f41f07b1cbede54e256e0029`)

client := newTestClient(t)

resp, err := NewFileCreateTransaction().
SetKeys(client.GetOperatorPublicKey()).
SetContents(testContractByteCode).
SetMaxTransactionFee(NewHbar(3)).
Execute(client)

assert.NoError(t, err)

receipt, err := resp.GetReceipt(client)
assert.NoError(t, err)

fileID := *receipt.FileID
assert.NotNil(t, fileID)

resp2, err := NewContractCreateTransaction().
SetAdminKey(client.GetOperatorPublicKey()).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
SetGas(2000).
SetBytecodeFileID(fileID).
Execute(client)
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf("exceptional precheck status INSUFFICIENT_TX_FEE received for transaction %s", resp2.TransactionID), err.Error())

_, err = resp2.GetReceipt(client)
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf("Invalid node AccountID was set for transaction: %s", resp2.NodeID), err.Error())

resp, err = NewFileDeleteTransaction().
SetFileID(fileID).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
SetMaxTransactionFee(NewHbar(5)).
Execute(client)
assert.NoError(t, err)

_, err = resp.GetReceipt(client)
assert.NoError(t, err)
}
69 changes: 0 additions & 69 deletions contract_execute_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,75 +226,6 @@ func Test_ContractExecute_NoFunction(t *testing.T) {
assert.NoError(t, err)
}

func Test_ContractExecuteTransaction_NoMaxFee(t *testing.T) {
client := newTestClient(t)

// Note: this is the bytecode for the contract found in the example for ./examples/create_simple_contract
testContractByteCode := []byte(`608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101cb806100606000396000f3fe608060405260043610610046576000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b51461004b578063cfae321714610062575b600080fd5b34801561005757600080fd5b506100606100f2565b005b34801561006e57600080fd5b50610077610162565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b757808201518184015260208101905061009c565b50505050905090810190601f1680156100e45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610160573373ffffffffffffffffffffffffffffffffffffffff16ff5b565b60606040805190810160405280600d81526020017f48656c6c6f2c20776f726c64210000000000000000000000000000000000000081525090509056fea165627a7a72305820ae96fb3af7cde9c0abfe365272441894ab717f816f07f41f07b1cbede54e256e0029`)

resp, err := NewFileCreateTransaction().
SetKeys(client.GetOperatorPublicKey()).
SetContents(testContractByteCode).
SetMaxTransactionFee(NewHbar(5)).
Execute(client)

assert.NoError(t, err)

receipt, err := resp.GetReceipt(client)
assert.NoError(t, err)

fileID := *receipt.FileID
assert.NotNil(t, fileID)

resp, err = NewContractCreateTransaction().
SetAdminKey(client.GetOperatorPublicKey()).
SetGas(2000).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
SetConstructorParameters(NewContractFunctionParameters().AddString("hello from hedera")).
SetBytecodeFileID(fileID).
SetContractMemo("hedera-sdk-go::TestContractDeleteTransaction_Execute").
SetMaxTransactionFee(NewHbar(20)).
Execute(client)
assert.NoError(t, err)

receipt, err = resp.GetReceipt(client)
assert.NoError(t, err)

assert.NotNil(t, receipt.ContractID)
contractID := *receipt.ContractID

resp2, err := NewContractExecuteTransaction().
SetContractID(contractID).
SetGas(10000).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
SetFunction("setMessage", NewContractFunctionParameters().AddString("new message")).
Execute(client)
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf("exceptional precheck status INSUFFICIENT_TX_FEE received for transaction %s", resp2.TransactionID), err.Error())

_, err = resp2.GetReceipt(client)
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf("Invalid node AccountID was set for transaction: %s", resp2.NodeID), err.Error())

resp, err = NewContractDeleteTransaction().
SetContractID(contractID).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
Execute(client)
assert.NoError(t, err)

_, err = resp.GetReceipt(client)
assert.NoError(t, err)

resp, err = NewFileDeleteTransaction().
SetFileID(fileID).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
Execute(client)
assert.NoError(t, err)

_, err = resp.GetReceipt(client)
assert.NoError(t, err)
}

//func Test_ContractExecuteTransaction_ID(t *testing.T) {
// client := newTestClient(t)
//
Expand Down
4 changes: 2 additions & 2 deletions file_append_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func Test_FileAppend_NothingSet(t *testing.T) {
SetContents([]byte(" world!")).
Execute(client)
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf("exceptional precheck status INSUFFICIENT_TX_FEE received for transaction %s", resp.TransactionID), err.Error())
assert.Equal(t, fmt.Sprintf("exceptional precheck status INVALID_FILE_ID"), err.Error())

_, err = resp.GetReceipt(client)
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf("Invalid node AccountID was set for transaction: %s", resp.NodeID), err.Error())
assert.Equal(t, fmt.Sprintf("exceptional precheck status INVALID_FILE_ID"), err.Error())
}
2 changes: 0 additions & 2 deletions token_create_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func Test_TokenCreate_NoKeys(t *testing.T) {

resp, err := NewAccountCreateTransaction().
SetKey(pubKeys[0]).
SetMaxTransactionFee(NewHbar(2)).
SetInitialBalance(newBalance).
Execute(client)
assert.NoError(t, err)
Expand Down Expand Up @@ -172,7 +171,6 @@ func Test_TokenCreate_AdminSign(t *testing.T) {

resp, err := NewAccountCreateTransaction().
SetKey(pubKeys[0]).
SetMaxTransactionFee(NewHbar(2)).
SetInitialBalance(newBalance).
Execute(client)
assert.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions utilities_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ func newTestClient(t *testing.T) *Client {
client.SetOperator(operatorAccountID, operatorKey)
}

client.SetMaxTransactionFee(NewHbar(50))

return client
}

0 comments on commit 566ccb1

Please sign in to comment.