diff --git a/assets/asset.go b/assets/asset.go index 7db83f6..05fbbfe 100644 --- a/assets/asset.go +++ b/assets/asset.go @@ -93,6 +93,9 @@ func (a *Asset) injectMetadata(stub *sw.StubWrapper) errors.ICCError { } (*a)["@lastUpdated"] = lastUpdated.AsTime().Format(time.RFC3339) + lastTxID := stub.Stub.GetTxID() + (*a)["@lastTxID"] = lastTxID + return nil } diff --git a/test/assets_put_test.go b/test/assets_put_test.go index 2415af3..8fe5ac2 100644 --- a/test/assets_put_test.go +++ b/test/assets_put_test.go @@ -25,6 +25,7 @@ func TestPutAsset(t *testing.T) { "@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19", "@lastTouchBy": "org1MSP", "@lastTx": "", + "@lastTxID": "TestPutAsset", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), "@assetType": "person", "name": "Maria", @@ -161,6 +162,7 @@ func TestPutNewAssetRecursive(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), + "@lastTxID": "TestPutAsset", "title": "Meu Nome é Maria", "author": "Maria Viana", "currentTenant": map[string]interface{}{ @@ -169,6 +171,7 @@ func TestPutNewAssetRecursive(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), + "@lastTxID": "TestPutAsset", "name": "Maria", "id": "31820792048", "height": 1.66, @@ -190,6 +193,7 @@ func TestPutNewAssetRecursive(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), + "@lastTxID": "TestPutAsset", "title": "Meu Nome é Maria", "author": "Maria Viana", "currentTenant": map[string]interface{}{ @@ -270,6 +274,7 @@ func TestUpdateRecursive(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), + "@lastTxID": "TestUpdateAsset", "title": "Meu Nome é Maria", "author": "Maria Viana", "currentTenant": map[string]interface{}{ @@ -278,6 +283,7 @@ func TestUpdateRecursive(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), + "@lastTxID": "TestUpdateAsset", "name": "Maria", "id": "31820792048", "height": 1.88, @@ -300,6 +306,7 @@ func TestUpdateRecursive(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), + "@lastTxID": "TestUpdateAsset", "title": "Meu Nome é Maria", "author": "Maria Viana", "currentTenant": map[string]interface{}{ diff --git a/test/tryout_test.go b/test/tryout_test.go index ab32099..11b06c2 100644 --- a/test/tryout_test.go +++ b/test/tryout_test.go @@ -27,6 +27,7 @@ func TestTryout(t *testing.T) { "@lastTouchBy": "org1MSP", "@lastTx": "createAsset", "@assetType": "person", + "@lastTxID": "createAsset", "name": "Maria", "id": "31820792048", "height": 0.0, @@ -63,6 +64,7 @@ func TestTryout(t *testing.T) { "@lastTouchBy": "org2MSP", "@lastTx": "createAsset", "@assetType": "book", + "@lastTxID": "createAsset", "title": "Meu Nome é Maria", "author": "Maria Viana", "currentTenant": map[string]interface{}{ @@ -116,6 +118,7 @@ func TestTryout(t *testing.T) { "@lastTouchBy": "org2MSP", "@lastTx": "updateAsset", "@assetType": "person", + "@lastTxID": "updateAsset", "name": "Maria", "id": "31820792048", "height": 1.67, diff --git a/test/tx_createAssetType_test.go b/test/tx_createAssetType_test.go index 781c5c5..1abf623 100644 --- a/test/tx_createAssetType_test.go +++ b/test/tx_createAssetType_test.go @@ -122,6 +122,7 @@ func TestCreateAssetType(t *testing.T) { "@lastTx": "createAsset", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), "@assetType": "magazine", + "@lastTxID": "createAsset", "name": "MAG", "images": []interface{}{ "url.com/1", diff --git a/test/tx_createAsset_test.go b/test/tx_createAsset_test.go index bc0bed8..4ac2320 100644 --- a/test/tx_createAsset_test.go +++ b/test/tx_createAsset_test.go @@ -39,6 +39,7 @@ func TestCreateAsset(t *testing.T) { "@lastTx": "createAsset", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), "@assetType": "person", + "@lastTxID": "createAsset", "name": "Maria", "id": "31820792048", "height": 0.0, @@ -139,6 +140,7 @@ func TestCreateAssetGenericAssociation(t *testing.T) { "@lastTx": "createAsset", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), "@assetType": "person", + "@lastTxID": "createAsset", "name": "Maria", "id": "31820792048", "height": 0.0, @@ -250,6 +252,7 @@ func TestCreatePrivate(t *testing.T) { "@assetType": "secret", "@lastTouchBy": "org2MSP", "@lastTx": "createAsset", + "@lastTxID": "createAsset", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), "secretName": "testSecret", "secret": "this is very secret", diff --git a/test/tx_updateAsset_test.go b/test/tx_updateAsset_test.go index 9787213..fe2f3da 100644 --- a/test/tx_updateAsset_test.go +++ b/test/tx_updateAsset_test.go @@ -71,6 +71,7 @@ func TestUpdateAsset(t *testing.T) { "@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19", "@lastTouchBy": "org1MSP", "@lastTx": "updateAsset", + "@lastTxID": "updateAsset", "@lastUpdated": lastUpdated.AsTime().Format(time.RFC3339), "@assetType": "person", "name": "Maria",