Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions base_layer/common_types/src/tari_address/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,6 @@ impl TariAddress {

/// helper function to convert emojis to u8
fn emoji_to_bytes(emoji: &str) -> Result<Vec<u8>, TariAddressError> {
// The string must be the correct size, including the checksum
if !(emoji.chars().count() == TARI_ADDRESS_INTERNAL_SINGLE_SIZE ||
emoji.chars().count() == TARI_ADDRESS_INTERNAL_DUAL_SIZE)
{
return Err(TariAddressError::InvalidSize);
}
if emoji.chars().count() == TARI_ADDRESS_INTERNAL_SINGLE_SIZE {
SingleAddress::emoji_to_bytes(emoji)
} else {
Expand Down Expand Up @@ -924,7 +918,7 @@ mod test {
Err(TariAddressError::InvalidSize)
);
// This emoji string is too long to be a valid emoji ID
let emoji_string = "🍗🌊🦂🍎🐛🔱🍟🚦🦆👃🐛🎼🛵🔮💋👙💦🍷👠🦀🐺🍪🚀🎮🎩👅🐔🐉🍍🥑💔📌🚧🐊💄🎥🎓🚗🎳🐛🚿💉🌴🧢🐵🎩👾👽🎃🤡👍🔮👒👽🎵👀🚨😷🎒👂👶🍄🏰🚑🌸🍁👂🎒";
let emoji_string = "🍗🌊🦂🍎🐛🔱🍟🚦🦆👃🐛🎼🛵🔮💋👙💦🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🐛🔱🍟🚦🦆👃🐛🎼🛵🔮💋👙💦🍷👠🐛🔱🍟🚦🦆👃🐛🎼🛵🔮💋👙💦🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🐛🔱🍟🚦🦆👃🐛🎼🛵🔮💋👙💦🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮🔱🍟🚦🦆👃🐛🎼🛵🔮💋👙💦🍷👠🦀🐺🛵🔮💋👙💦🍷👠💦🍷👠🦀🐺🛵🔮💋👙💦🍷👠🦀🐺🍪🚀🎮🎩👅🐔🐉🍍🥑💔📌🚧🐊💄🎥🎓🚗🎳🐛🚿💉🌴🧢🐵🎩👾👽🎃🤡👍🔮👒👽🎵👀🚨😷🎒👂👶🍄🎩👾👽🎃🤡👍🔮👒👽🎵👀🚨😷🎒👂👶🍄🏰🚑🌸🍁👂🎒💉🌴🧢🐵🎩👾👽🎃🤡👍🔮👒👽🎵👀🚨😷🎒👂👶🍄🏰🚑🌸🍁👂🎒";
assert_eq!(
TariAddress::from_emoji_string(emoji_string),
Err(TariAddressError::InvalidSize)
Expand Down Expand Up @@ -995,14 +989,14 @@ mod test {
// This emoji string contains an invalid utf8 character
let emoji_string = "🦊 | 🦊 | 🦊 | 🦊 | 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | \
🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊| 🦊 | \
🦊| 🦊 | 🦊| 🦊 | 🦊";
🦊| 🦊 | 🦊| 🦊 | 🦊 | 🦊| 🦊 | 🦊| 🦊 | 🦊";
assert_eq!(
TariAddress::from_base58(emoji_string),
Err(TariAddressError::InvalidCharacter)
);
assert_eq!(
TariAddress::from_emoji_string(emoji_string),
Err(TariAddressError::InvalidSize)
Err(TariAddressError::InvalidEmoji)
);
assert_eq!(
TariAddress::from_str(emoji_string),
Expand Down
3 changes: 3 additions & 0 deletions base_layer/core/tests/tests/horizon_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use crate::helpers::{
};

#[allow(clippy::too_many_lines)]
#[ignore = "prune mode not yet working"]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_initial_horizon_sync_from_archival_node_happy_path() {
//` cargo test --release --test core_integration_tests
Expand Down Expand Up @@ -284,6 +285,7 @@ async fn test_initial_horizon_sync_from_archival_node_happy_path() {
}

#[allow(clippy::too_many_lines)]
#[ignore = "prune mode not yet working"]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_consecutive_horizon_sync_from_prune_node_happy_path() {
//` cargo test --release --test core_integration_tests
Expand Down Expand Up @@ -662,6 +664,7 @@ async fn test_consecutive_horizon_sync_from_prune_node_happy_path() {
}

#[allow(clippy::too_many_lines)]
#[ignore = "prune mode not yet working"]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_initial_horizon_sync_from_prune_node_happy_path() {
//` cargo test --release --test core_integration_tests
Expand Down
32 changes: 26 additions & 6 deletions base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ use tari_common::{
use tari_common_sqlite::connection::DbConnectionUrl;
use tari_common_types::{
emoji::{emoji_set, EMOJI},
tari_address::{TariAddress, TariAddressError},
tari_address::TariAddress,
transaction::{TransactionDirection, TransactionStatus, TxId},
types::{
ComAndPubSignature,
Expand Down Expand Up @@ -1968,11 +1968,14 @@ pub unsafe extern "C" fn emoji_id_to_tari_address(
return ptr::null_mut();
}

match CStr::from_ptr(emoji)
.to_str()
.map_err(|_| TariAddressError::InvalidEmoji)
.and_then(TariAddress::from_emoji_string)
{
let cstring = match CStr::from_ptr(emoji).to_str() {
Ok(v) => v.to_owned(),
Err(_) => {
*error_out = LibWalletError::from(InterfaceError::InvalidEmojiId).code;
return ptr::null_mut();
},
};
match TariAddress::from_emoji_string(&cstring) {
Ok(address) => Box::into_raw(Box::new(address)),
Err(_) => {
*error_out = LibWalletError::from(InterfaceError::InvalidEmojiId).code;
Expand Down Expand Up @@ -10924,6 +10927,23 @@ mod test {
}
}

#[test]
fn test_emoji_string() {
unsafe {
let mut error = 0;
let error_ptr = &mut error as *mut c_int;
let emoji_string = "🐢🐋🏦💤🐣👣📱🚜🍍🍉🎺🥊📖🔦😷👾🐺🐬👗🔱🌻💍🎢🎪🛵🐋🐊👞🥝🐍🌸📷🔧🎭🐮⏰🍇💯🐛🌴💨🔌🍪📟🎲🐝🤢🎉🔑🌵🚒🐙😍🐝🍑🐜👂🧩⏰🎀🚀🍵👑💐🎮🎮🎣🎒🍬🍳🍸🍷🍶🍯🍵🥄🍭🥐💣";

let _tari_address = TariAddress::from_emoji_string(emoji_string).unwrap();

let cstring = CString::new(emoji_string).unwrap();
let cstring_ptr: *const c_char = CString::into_raw(cstring) as *const c_char;

let _result = emoji_id_to_tari_address(cstring_ptr, error_ptr);
assert_eq!(*error_ptr, 0, "No error expected");
}
}

#[test]
fn test_emoji_convert() {
unsafe {
Expand Down
Loading