Skip to content

Commit 36ad9fd

Browse files
committed
[FAB-14149] tx protos cleanup
-- rename PlainOutput Token -- remove Plain from the names -- rename Import Issue -- refactor code accordingly Change-Id: I9cecdaead5154f5d4e3dc59f9c128574f2c94c4d Signed-off-by: Kaoutar Elkhiyaoui <kao@zurich.ibm.com>
1 parent 946f86b commit 36ad9fd

25 files changed

+832
-804
lines changed

core/committer/txvalidator/v14/validator_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ func getEnvWithSigner(ccID string, event []byte, res []byte, sig msp.SigningIden
204204

205205
func getTokenTx(t *testing.T) *common.Envelope {
206206
transactionData := &token.TokenTransaction{
207-
Action: &token.TokenTransaction_PlainAction{
208-
PlainAction: &token.PlainTokenAction{
209-
Data: &token.PlainTokenAction_PlainImport{
210-
PlainImport: &token.PlainImport{
211-
Outputs: []*token.PlainOutput{
207+
Action: &token.TokenTransaction_TokenAction{
208+
TokenAction: &token.TokenAction{
209+
Data: &token.TokenAction_Issue{
210+
Issue: &token.Issue{
211+
Outputs: []*token.Token{
212212
{Owner: &token.TokenOwner{Raw: []byte("owner-1")}, Type: "TOK1", Quantity: 111},
213213
{Owner: &token.TokenOwner{Raw: []byte("owner-2")}, Type: "TOK2", Quantity: 222},
214214
},

core/committer/txvalidator/v20/validator_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ func getEnvWithSigner(ccID string, event []byte, res []byte, sig msp.SigningIden
152152

153153
func getTokenTx(t *testing.T) *common.Envelope {
154154
transactionData := &token.TokenTransaction{
155-
Action: &token.TokenTransaction_PlainAction{
156-
PlainAction: &token.PlainTokenAction{
157-
Data: &token.PlainTokenAction_PlainImport{
158-
PlainImport: &token.PlainImport{
159-
Outputs: []*token.PlainOutput{
155+
Action: &token.TokenTransaction_TokenAction{
156+
TokenAction: &token.TokenAction{
157+
Data: &token.TokenAction_Issue{
158+
Issue: &token.Issue{
159+
Outputs: []*token.Token{
160160
{Owner: &token.TokenOwner{Raw: []byte("owner-1")}, Type: "TOK1", Quantity: 111},
161161
{Owner: &token.TokenOwner{Raw: []byte("owner-2")}, Type: "TOK2", Quantity: 222},
162162
},

core/common/validation/msgvalidation_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func protoMarshal(t *testing.T, m proto.Message) []byte {
7272
// getTokenTransaction returns a valid token transaction
7373
func getTokenTransaction() *token.TokenTransaction {
7474
return &token.TokenTransaction{
75-
Action: &token.TokenTransaction_PlainAction{
76-
PlainAction: &token.PlainTokenAction{
77-
Data: &token.PlainTokenAction_PlainImport{
78-
PlainImport: &token.PlainImport{
79-
Outputs: []*token.PlainOutput{{
75+
Action: &token.TokenTransaction_TokenAction{
76+
TokenAction: &token.TokenAction{
77+
Data: &token.TokenAction_Issue{
78+
Issue: &token.Issue{
79+
Outputs: []*token.Token{{
8080
Owner: &token.TokenOwner{Raw: []byte("token-owner")},
8181
Type: "PDQ",
8282
Quantity: 777,

integration/token/token_test.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ var _ = Describe("Token EndToEnd", func() {
5656

5757
// expected token transaction returned by prover peer
5858
expectedTokenTransaction = &token.TokenTransaction{
59-
Action: &token.TokenTransaction_PlainAction{
60-
PlainAction: &token.PlainTokenAction{
61-
Data: &token.PlainTokenAction_PlainImport{
62-
PlainImport: &token.PlainImport{
63-
Outputs: []*token.PlainOutput{{
59+
Action: &token.TokenTransaction_TokenAction{
60+
TokenAction: &token.TokenAction{
61+
Data: &token.TokenAction_Issue{
62+
Issue: &token.Issue{
63+
Outputs: []*token.Token{{
6464
Owner: &token.TokenOwner{Raw: []byte("test-owner")},
6565
Type: "ABC123",
6666
Quantity: 119,
6767
}}}}}}}
6868
expectedTransferTransaction = &token.TokenTransaction{
69-
Action: &token.TokenTransaction_PlainAction{
70-
PlainAction: &token.PlainTokenAction{
71-
Data: &token.PlainTokenAction_PlainTransfer{
72-
PlainTransfer: &token.PlainTransfer{
69+
Action: &token.TokenTransaction_TokenAction{
70+
TokenAction: &token.TokenAction{
71+
Data: &token.TokenAction_Transfer{
72+
Transfer: &token.Transfer{
7373
Inputs: nil,
74-
Outputs: []*token.PlainOutput{{
74+
Outputs: []*token.Token{{
7575
Owner: nil,
7676
Type: "ABC123",
7777
Quantity: 119,
@@ -82,12 +82,12 @@ var _ = Describe("Token EndToEnd", func() {
8282
},
8383
}
8484
expectedRedeemTransaction = &token.TokenTransaction{
85-
Action: &token.TokenTransaction_PlainAction{
86-
PlainAction: &token.PlainTokenAction{
87-
Data: &token.PlainTokenAction_PlainRedeem{
88-
PlainRedeem: &token.PlainTransfer{
85+
Action: &token.TokenTransaction_TokenAction{
86+
TokenAction: &token.TokenAction{
87+
Data: &token.TokenAction_Redeem{
88+
Redeem: &token.Transfer{
8989
Inputs: nil,
90-
Outputs: []*token.PlainOutput{
90+
Outputs: []*token.Token{
9191
{
9292
Owner: nil,
9393
Type: "ABC123",
@@ -155,12 +155,12 @@ var _ = Describe("Token EndToEnd", func() {
155155
Expect(err).NotTo(HaveOccurred())
156156
recipientUser2 = &token.TokenOwner{Raw: recipientUser2Bytes}
157157
tokensToIssue[0].Recipient = recipientUser2
158-
expectedTokenTransaction.GetPlainAction().GetPlainImport().Outputs[0].Owner = recipientUser2
158+
expectedTokenTransaction.GetTokenAction().GetIssue().Outputs[0].Owner = recipientUser2
159159
recipientUser1Bytes, err := getIdentity(network, peer, "User1", "Org1MSP")
160160
Expect(err).NotTo(HaveOccurred())
161161
recipientUser1 = &token.TokenOwner{Raw: recipientUser1Bytes}
162-
expectedTransferTransaction.GetPlainAction().GetPlainTransfer().Outputs[0].Owner = recipientUser1
163-
expectedRedeemTransaction.GetPlainAction().GetPlainRedeem().Outputs[1].Owner = recipientUser1
162+
expectedTransferTransaction.GetTokenAction().GetTransfer().Outputs[0].Owner = recipientUser1
163+
expectedRedeemTransaction.GetTokenAction().GetRedeem().Outputs[1].Owner = recipientUser1
164164

165165
networkRunner := network.NetworkGroupRunner()
166166
process = ifrit.Invoke(networkRunner)
@@ -199,7 +199,7 @@ var _ = Describe("Token EndToEnd", func() {
199199

200200
By("transferring tokens to user1")
201201
tokenIDs := []*token.TokenId{{TxId: txID, Index: 0}}
202-
expectedTransferTransaction.GetPlainAction().GetPlainTransfer().Inputs = tokenIDs
202+
expectedTransferTransaction.GetTokenAction().GetTransfer().Inputs = tokenIDs
203203
txID = RunTransferRequest(tClient, issuedTokens, recipientUser1, expectedTransferTransaction)
204204

205205
By("list tokens user 2")
@@ -218,7 +218,7 @@ var _ = Describe("Token EndToEnd", func() {
218218

219219
By("redeeming tokens user1")
220220
tokenIDs = []*token.TokenId{{TxId: txID, Index: 0}}
221-
expectedRedeemTransaction.GetPlainAction().GetPlainRedeem().Inputs = tokenIDs
221+
expectedRedeemTransaction.GetTokenAction().GetRedeem().Inputs = tokenIDs
222222
quantityToRedeem := 50 // redeem 50 out of 119
223223
RunRedeemRequest(tClient, issuedTokens, uint64(quantityToRedeem), expectedRedeemTransaction)
224224

@@ -264,11 +264,11 @@ var _ = Describe("Token EndToEnd", func() {
264264
Expect(err).NotTo(HaveOccurred())
265265
recipientUser2 = &token.TokenOwner{Raw: recipientUser2Bytes}
266266
tokensToIssue[0].Recipient = &token.TokenOwner{Raw: recipientUser2Bytes}
267-
expectedTokenTransaction.GetPlainAction().GetPlainImport().Outputs[0].Owner = recipientUser2
267+
expectedTokenTransaction.GetTokenAction().GetIssue().Outputs[0].Owner = recipientUser2
268268
recipientUser1Bytes, err := getIdentity(network, peer, "User1", "Org1MSP")
269269
Expect(err).NotTo(HaveOccurred())
270270
recipientUser1 = &token.TokenOwner{Raw: recipientUser1Bytes}
271-
expectedTransferTransaction.GetPlainAction().GetPlainTransfer().Outputs[0].Owner = &token.TokenOwner{Raw: recipientUser1Bytes}
271+
expectedTransferTransaction.GetTokenAction().GetTransfer().Outputs[0].Owner = &token.TokenOwner{Raw: recipientUser1Bytes}
272272

273273
networkRunner := network.NetworkGroupRunner()
274274
process = ifrit.Invoke(networkRunner)
@@ -294,7 +294,7 @@ var _ = Describe("Token EndToEnd", func() {
294294

295295
By("User2 transfers his token to User1")
296296
inputIDs := []*token.TokenId{{TxId: txID, Index: 0}}
297-
expectedTransferTransaction.GetPlainAction().GetPlainTransfer().Inputs = inputIDs
297+
expectedTransferTransaction.GetTokenAction().GetTransfer().Inputs = inputIDs
298298
RunTransferRequest(tClient, issuedTokens, recipientUser1, expectedTransferTransaction)
299299

300300
By("User2 try to transfer again the same token already transferred before")
@@ -326,12 +326,12 @@ var _ = Describe("Token EndToEnd", func() {
326326

327327
By("User1 attempts to spend User2's tokens by submitting a token transaction directly")
328328
expectedTokenTransaction = &token.TokenTransaction{
329-
Action: &token.TokenTransaction_PlainAction{
330-
PlainAction: &token.PlainTokenAction{
331-
Data: &token.PlainTokenAction_PlainTransfer{
332-
PlainTransfer: &token.PlainTransfer{
329+
Action: &token.TokenTransaction_TokenAction{
330+
TokenAction: &token.TokenAction{
331+
Data: &token.TokenAction_Transfer{
332+
Transfer: &token.Transfer{
333333
Inputs: []*token.TokenId{{TxId: txID, Index: 0}},
334-
Outputs: []*token.PlainOutput{{
334+
Outputs: []*token.Token{{
335335
Owner: &token.TokenOwner{Raw: []byte("test-owner")},
336336
Type: "ABC123",
337337
Quantity: 119,
@@ -421,9 +421,9 @@ func RunTransferRequest(c *tokenclient.Client, inputTokens []*token.TokenOutput,
421421
Expect(tokenTxid).To(Equal(txid))
422422

423423
// Verify the result
424-
Expect(tokenTx.GetPlainAction().GetPlainTransfer().GetInputs()).ToNot(BeNil())
425-
Expect(len(tokenTx.GetPlainAction().GetPlainTransfer().GetInputs())).To(Equal(1))
426-
Expect(tokenTx.GetPlainAction().GetPlainTransfer().GetOutputs()).ToNot(BeNil())
424+
Expect(tokenTx.GetTokenAction().GetTransfer().GetInputs()).ToNot(BeNil())
425+
Expect(len(tokenTx.GetTokenAction().GetTransfer().GetInputs())).To(Equal(1))
426+
Expect(tokenTx.GetTokenAction().GetTransfer().GetOutputs()).ToNot(BeNil())
427427

428428
return txid
429429
}

protos/token/expectations.pb.go

Lines changed: 46 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/token/expectations.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ option java_package = "org.hyperledger.fabric.protos.token";
1111

1212
package token;
1313

14-
import "google/protobuf/timestamp.proto";
1514
import "token/transaction.proto";
1615

1716
// TokenExpectation represent the belief that someone should achieve in terms of a token action
@@ -36,5 +35,5 @@ message PlainExpectation {
3635
// certain outputs will be matched
3736
message PlainTokenExpectation {
3837
// Outputs contains the expected outputs
39-
repeated PlainOutput outputs = 1;
38+
repeated Token outputs = 1;
4039
}

0 commit comments

Comments
 (0)