-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for no-alloc using static lifetime ref Box and Vec types
- Loading branch information
1 parent
17f837c
commit cb2224a
Showing
6 changed files
with
183 additions
and
35 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ base64 = "0.13.0" | |
|
||
[features] | ||
default = ["std"] | ||
std = ["base64/std"] | ||
std = ["alloc", "base64/std"] | ||
alloc = [] |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use stellar_xdr::*; | ||
|
||
#[cfg(feature = "std")] | ||
#[test] | ||
fn test_build_small_tx_with_std() -> Result<(), Error> { | ||
let te = TransactionEnvelope::EnvelopeTypeTx(TransactionV1Envelope { | ||
tx: Transaction { | ||
source_account: MuxedAccount::KeyTypeEd25519(Uint256([0; 32])), | ||
fee: 0, | ||
seq_num: SequenceNumber(1), | ||
cond: Preconditions::PrecondNone, | ||
memo: Memo::MemoText("Stellar".as_bytes().try_into()?), | ||
operations: [].to_vec().try_into()?, | ||
ext: TransactionExt::V0, | ||
}, | ||
signatures: [].try_into()?, | ||
}); | ||
let xdr = te.to_xdr_base64()?; | ||
assert_eq!(xdr, "AAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAB1N0ZWxsYXIAAAAAAAAAAAAAAAAA"); | ||
Ok(()) | ||
} | ||
|
||
#[cfg(feature = "alloc")] | ||
#[test] | ||
fn test_build_small_tx_with_alloc() -> Result<(), Error> { | ||
let _ = TransactionEnvelope::EnvelopeTypeTx(TransactionV1Envelope { | ||
tx: Transaction { | ||
source_account: MuxedAccount::KeyTypeEd25519(Uint256([0; 32])), | ||
fee: 0, | ||
seq_num: SequenceNumber(1), | ||
cond: Preconditions::PrecondNone, | ||
memo: Memo::MemoText("Stellar".as_bytes().try_into()?), | ||
operations: [].to_vec().try_into()?, | ||
ext: TransactionExt::V0, | ||
}, | ||
signatures: [].try_into()?, | ||
}); | ||
Ok(()) | ||
} | ||
|
||
#[cfg(not(feature = "alloc"))] | ||
#[test] | ||
fn test_build_small_tx_with_alloc() -> Result<(), Error> { | ||
let _ = TransactionEnvelope::EnvelopeTypeTx(TransactionV1Envelope { | ||
tx: Transaction { | ||
source_account: MuxedAccount::KeyTypeEd25519(Uint256([0; 32])), | ||
fee: 0, | ||
seq_num: SequenceNumber(1), | ||
cond: Preconditions::PrecondNone, | ||
memo: Memo::MemoText("Stellar".as_bytes().try_into()?), | ||
operations: (&[]).try_into()?, | ||
ext: TransactionExt::V0, | ||
}, | ||
signatures: (&[]).try_into()?, | ||
}); | ||
Ok(()) | ||
} |