forked from cryptonotefoundation/cryptonote
-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More swap wip #238
Merged
Merged
More swap wip #238
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d5af6c
Func for checking for swap tx
bubafistah 548604b
Swap addr parsing
bubafistah 66c9387
Update unittests
bubafistah e4a2146
Send swap txs to null addr
bubafistah 7dcf37f
Add swap data to tx when constructing
bubafistah a845f2f
Add missing func def
bubafistah 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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#include "gtest/gtest.h" | ||
#include "cryptonote_basic/cryptonote_basic.h" | ||
#include "cryptonote_basic/cryptonote_format_utils.h" | ||
#include "cryptonote_core/cryptonote_tx_utils.h" | ||
#include "crypto/random.h" | ||
#include "cryptonote_core/swap_address.h" | ||
|
||
|
@@ -17,6 +18,46 @@ TEST(swap_address, swap_addr_extra_userdata_entry_from_addr) | |
ASSERT_TRUE(entry.is_checksum_valid()); | ||
} | ||
|
||
TEST(swap_address, swap_parse_addr_from_str) | ||
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. Yay, code with a test, we are like adults now... my word, what happened :P |
||
{ | ||
cryptonote::account_public_address new_chain_addr = AUTO_VAL_INIT(new_chain_addr); | ||
cryptonote::account_public_address old_chain_addr = AUTO_VAL_INIT(old_chain_addr); | ||
cryptonote::account_public_address invalid_addr = AUTO_VAL_INIT(invalid_addr); | ||
|
||
std::string new_chain_addr_str = "iTxtQTLo1H8aGripS8mzG6c1Y3WcoSzzBFb4o7o2xUJmfJgLxxscutm9s9EMYXYnaaUN1E1XpMUHREcFbqAeSBzk61pYu2Tjhs"; | ||
std::string old_chain_addr_str = "iz5vDmtTSk7cyKdHr6Jv7vVSpx3thD6wGdXuyETg81KBfSVsZKeBewQUBF25uAtbJ3j9sHJzVHKfSNPu9aYbBnSv239GjxfER"; | ||
std::string invalid_addr_str = "n05vDmtTSk7cyKdHr6Jv7vVSpx3thD6wGdXuyETg81KBfSVsZKeBewQUBF25uAtbJ3j9sHJzVHKfSNPu9aYbBnSv239GjxfER"; | ||
|
||
bool has_payment_id; | ||
crypto::hash8 payment_id; | ||
|
||
ASSERT_TRUE( | ||
cryptonote::get_account_integrated_address_from_str(new_chain_addr, | ||
has_payment_id, | ||
payment_id, | ||
false, | ||
new_chain_addr_str) | ||
); | ||
ASSERT_TRUE(new_chain_addr.is_swap_addr); | ||
|
||
ASSERT_TRUE( | ||
cryptonote::get_account_integrated_address_from_str(old_chain_addr, | ||
has_payment_id, | ||
payment_id, | ||
false, | ||
old_chain_addr_str) | ||
); | ||
ASSERT_FALSE(old_chain_addr.is_swap_addr); | ||
|
||
ASSERT_FALSE( | ||
cryptonote::get_account_integrated_address_from_str(invalid_addr, | ||
has_payment_id, | ||
payment_id, | ||
false, | ||
invalid_addr_str) | ||
); | ||
} | ||
|
||
TEST(swap_tx, fill_tx_extra) | ||
{ | ||
cryptonote::transaction tx = AUTO_VAL_INIT(tx); | ||
|
@@ -55,4 +96,10 @@ TEST(swap_tx, fill_tx_extra) | |
|
||
ASSERT_EQ(swap_addr.m_spend_public_key, swap_addr2.m_spend_public_key); | ||
ASSERT_EQ(swap_addr.m_view_public_key, swap_addr2.m_view_public_key); | ||
|
||
vector<cryptonote::tx_destination_entry> fake_dest = { | ||
cryptonote::tx_destination_entry(80085, swap_addr) | ||
}; | ||
|
||
ASSERT_TRUE(cryptonote::is_swap_tx(tx, fake_dest)); | ||
} |
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.
Could we do an impossible key, like
000000000000000000000000000000000000000
?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.
Not sure, for now will just implement boolberry logic. Will have some free time by the end of the week, then i will give some more precise answer.