This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 296
Add oneof case bound check #1502
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9982ca
Add check for Command variant case
l4l 0bf70cb
Add check for Query variant case
l4l 467f010
Simplify oneof check
l4l 69663dd
Add tests for unset protobuf oneof
l4l 8572628
Merge branch 'develop' into fix/vars_case
l4l 7b40ac4
Add review fixes
l4l a32cabd
Remove redundant cmd clearing
l4l File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ class TransactionValidatorTest : public ValidatorsTest { | |
.getTransport(); | ||
return tx; | ||
} | ||
shared_model::validation::DefaultTransactionValidator transaction_validator; | ||
}; | ||
|
||
/** | ||
|
@@ -49,7 +50,6 @@ class TransactionValidatorTest : public ValidatorsTest { | |
TEST_F(TransactionValidatorTest, EmptyTransactionTest) { | ||
auto tx = generateEmptyTransaction(); | ||
tx.mutable_payload()->set_created_time(created_time); | ||
shared_model::validation::DefaultTransactionValidator transaction_validator; | ||
auto result = proto::Transaction(iroha::protocol::Transaction(tx)); | ||
auto answer = transaction_validator.validate(result); | ||
ASSERT_EQ(answer.getReasonsMap().size(), 1); | ||
|
@@ -101,13 +101,26 @@ TEST_F(TransactionValidatorTest, StatelessValidTest) { | |
}, | ||
[] {}); | ||
|
||
shared_model::validation::DefaultTransactionValidator transaction_validator; | ||
auto result = proto::Transaction(iroha::protocol::Transaction(tx)); | ||
auto answer = transaction_validator.validate(result); | ||
|
||
ASSERT_FALSE(answer.hasErrors()) << answer.reason(); | ||
} | ||
|
||
/** | ||
* @given Protobuf transaction object with unset command | ||
* @when validate is called | ||
* @then there is a error returned | ||
*/ | ||
TEST_F(TransactionValidatorTest, UnsetCommand) { | ||
iroha::protocol::Transaction tx = generateEmptyTransaction(); | ||
tx.mutable_payload()->set_creator_account_id(account_id); | ||
tx.mutable_payload()->set_created_time(created_time); | ||
auto answer = transaction_validator.validate(proto::Transaction(tx)); | ||
tx.mutable_payload()->add_commands()->clear_add_asset_quantity(); | ||
ASSERT_TRUE(answer.hasErrors()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Answer here is |
||
} | ||
|
||
/** | ||
* @given transaction made of commands with invalid fields | ||
* @when commands validation is invoked | ||
|
@@ -136,7 +149,6 @@ TEST_F(TransactionValidatorTest, StatelessInvalidTest) { | |
}, | ||
[] {}); | ||
|
||
shared_model::validation::DefaultTransactionValidator transaction_validator; | ||
auto result = proto::Transaction(iroha::protocol::Transaction(tx)); | ||
auto answer = transaction_validator.validate(result); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussion, it seems that
clear_add_asset_quantity()
is redundant, sinceadd_commands()
does not setadd_asset_quantity
by default, and compiler won't probably optimize any calls. Soclear_add_asset_quantity()
call can be removed.