mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Fix param sequence in smartcontract
smartcontract_test. Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
This commit is contained in:
parent
09ebf1c1ce
commit
aa3ae32afb
2 changed files with 8 additions and 8 deletions
|
|
@ -54,7 +54,7 @@ func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface)
|
|||
}
|
||||
|
||||
// CreateAsset issues a new asset to the world state with given details.
|
||||
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id, color, owner string, size, appraisedValue int) error {
|
||||
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisedValue int) error {
|
||||
exists, err := s.AssetExists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -98,7 +98,7 @@ func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, i
|
|||
}
|
||||
|
||||
// UpdateAsset updates an existing asset in the world state with provided parameters.
|
||||
func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id, color, owner string, size, appraisedValue int) error {
|
||||
func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisedValue int) error {
|
||||
exists, err := s.AssetExists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -48,15 +48,15 @@ func TestCreateAsset(t *testing.T) {
|
|||
transactionContext.GetStubReturns(chaincodeStub)
|
||||
|
||||
assetTransfer := chaincode.SmartContract{}
|
||||
err := assetTransfer.CreateAsset(transactionContext, "", "", "", 0, 0)
|
||||
err := assetTransfer.CreateAsset(transactionContext, "", "", 0, "", 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
chaincodeStub.GetStateReturns([]byte{}, nil)
|
||||
err = assetTransfer.CreateAsset(transactionContext, "asset1", "", "", 0, 0)
|
||||
err = assetTransfer.CreateAsset(transactionContext, "asset1", "", 0, "", 0)
|
||||
require.EqualError(t, err, "the asset asset1 already exists")
|
||||
|
||||
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
|
||||
err = assetTransfer.CreateAsset(transactionContext, "asset1", "", "", 0, 0)
|
||||
err = assetTransfer.CreateAsset(transactionContext, "asset1", "", 0, "", 0)
|
||||
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
|
||||
}
|
||||
|
||||
|
|
@ -96,15 +96,15 @@ func TestUpdateAsset(t *testing.T) {
|
|||
|
||||
chaincodeStub.GetStateReturns(bytes, nil)
|
||||
assetTransfer := chaincode.SmartContract{}
|
||||
err = assetTransfer.UpdateAsset(transactionContext, "", "", "", 0, 0)
|
||||
err = assetTransfer.UpdateAsset(transactionContext, "", "", 0, "", 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
chaincodeStub.GetStateReturns(nil, nil)
|
||||
err = assetTransfer.UpdateAsset(transactionContext, "asset1", "", "", 0, 0)
|
||||
err = assetTransfer.UpdateAsset(transactionContext, "asset1", "", 0, "", 0)
|
||||
require.EqualError(t, err, "the asset asset1 does not exist")
|
||||
|
||||
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
|
||||
err = assetTransfer.UpdateAsset(transactionContext, "asset1", "", "", 0, 0)
|
||||
err = assetTransfer.UpdateAsset(transactionContext, "asset1", "", 0, "", 0)
|
||||
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue