Skip to content
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

AccountTrace Serialization was done in the wrong order #544

Merged
merged 29 commits into from
Dec 17, 2024
Merged
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c1d8caf
Invert order of vec
Kayanski Nov 21, 2024
463cacf
collect trace from string in single iteration
Buckram123 Nov 21, 2024
2ad544f
account trace parsing funtion
Kayanski Nov 22, 2024
92263dd
Merge branch 'fix/account-trace-serialization' of github.com:Abstract…
Kayanski Nov 22, 2024
34dd490
Removed unused
Kayanski Nov 22, 2024
b49de9b
add minimal snapshot test for multihop account
Buckram123 Nov 22, 2024
101bf20
found state bug
Buckram123 Nov 22, 2024
b692c84
add failing tests
Buckram123 Nov 22, 2024
562f4f5
fix AccountTrace key, but not the composite
Buckram123 Nov 22, 2024
3bbd505
Fix multi-hop test
Kayanski Nov 25, 2024
191f9c8
Better account id storage serialization
Kayanski Nov 26, 2024
798070e
Modify key deserialize impl
Kayanski Nov 26, 2024
4e30a6a
formatting [skip ci]
Kayanski Nov 26, 2024
198d476
Insta testsé
Kayanski Nov 26, 2024
d054df6
Fixing tests
Kayanski Nov 26, 2024
1bbb974
Hakari
Kayanski Nov 27, 2024
4c869d2
Added account multi-hop test
Kayanski Nov 27, 2024
6570cee
Added tests, reduce length
Kayanski Nov 27, 2024
e73d458
Redice max trace length
Kayanski Nov 27, 2024
2ef51d5
Update snaps
Kayanski Nov 27, 2024
259a9e6
Merge branch 'main' into fix/account-trace-serialization
Kayanski Nov 27, 2024
cca6384
Merge branch 'fix/account-trace-serialization' of github.com:Abstract…
Kayanski Nov 27, 2024
d191760
Trace length back to 6
Kayanski Nov 27, 2024
e372c07
Merge remote-tracking branch 'origin/main' into fix/account-trace-ser…
Kayanski Dec 16, 2024
9f7bc8f
Finalize nits
Kayanski Dec 17, 2024
54ddd19
Changed versions
Kayanski Dec 17, 2024
b6aed36
snaps
Kayanski Dec 17, 2024
84927ed
Reset because not verified
Kayanski Dec 17, 2024
10738e3
Format change
Kayanski Dec 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,13 @@
let acc = if trace == LOCAL {
Self::Local
} else {
Self::Remote(
trace
.split(CHAIN_DELIMITER)
.map(TruncatedChainId::_from_str)
.collect(),
)
let rev_trace: Vec<_> = trace
Kayanski marked this conversation as resolved.
Show resolved Hide resolved
// DoubleEndedSearcher implemented for char, but not for "str"
.split(CHAIN_DELIMITER.chars().next().unwrap())
.map(TruncatedChainId::_from_str)
.rev()
.collect();
Self::Remote(rev_trace)
};
acc.verify()?;
Ok(acc)
Expand All @@ -190,15 +191,7 @@
type Error = AbstractError;

fn try_from(trace: &str) -> Result<Self, Self::Error> {
if trace == LOCAL {
Ok(Self::Local)
} else {
let chain_trace: Vec<TruncatedChainId> = trace
.split(CHAIN_DELIMITER)
.map(|t| TruncatedChainId::from_string(t.to_string()))
.collect::<Result<Vec<_>, _>>()?;
Ok(Self::Remote(chain_trace))
}
AccountTrace::from_str(trace)

Check warning on line 194 in framework/packages/abstract-std/src/objects/account/account_trace.rs

View check run for this annotation

Codecov / codecov/patch

framework/packages/abstract-std/src/objects/account/account_trace.rs#L194

Added line #L194 was not covered by tests
}
}

Expand All @@ -212,6 +205,7 @@
// "juno>terra>osmosis"
chain_name
.iter()
.rev()
.map(|name| name.as_str())
.collect::<Vec<&str>>()
.join(CHAIN_DELIMITER)
Expand Down Expand Up @@ -255,25 +249,29 @@

#[coverage_helper::test]
fn remote_multi_works() {
// Here the account originates from ethereum and was then bridged to bitcoin
let trace = AccountTrace::from_str("bitcoin>ethereum").unwrap();
assert_eq!(
trace,
// The trace vector pushes the last chains last
AccountTrace::Remote(vec![
TruncatedChainId::from_str("ethereum").unwrap(),
TruncatedChainId::from_str("bitcoin").unwrap(),
TruncatedChainId::from_str("ethereum").unwrap()
])
);
}

#[coverage_helper::test]
fn remote_multi_multi_works() {
// Here the account originates from cosmos, and was then bridged to ethereum and was then bridged to bitcoin
let trace = AccountTrace::from_str("bitcoin>ethereum>cosmos").unwrap();
assert_eq!(
trace,
// The trace vector pushes the last chains last
AccountTrace::Remote(vec![
TruncatedChainId::from_str("bitcoin").unwrap(),
TruncatedChainId::from_str("ethereum").unwrap(),
TruncatedChainId::from_str("cosmos").unwrap(),
TruncatedChainId::from_str("ethereum").unwrap(),
TruncatedChainId::from_str("bitcoin").unwrap(),
])
);
}
Expand Down
Loading