Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

add more tx tests #11038

Merged
merged 1 commit into from
Sep 12, 2019
Merged
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
20 changes: 19 additions & 1 deletion ethcore/types/src/transaction/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ impl Default for Action {
impl rlp::Decodable for Action {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
if rlp.is_empty() {
Ok(Action::Create)
if rlp.is_data() {
Ok(Action::Create)
} else {
Err(DecoderError::RlpExpectedToBeData)
}
} else {
Ok(Action::Call(rlp.as_val()?))
}
Expand Down Expand Up @@ -571,6 +575,20 @@ mod tests {
assert_eq!(t.chain_id(), None);
}

#[test]
fn empty_atom_as_create_action() {
let empty_atom = [0x80];
let action: Action = rlp::decode(&empty_atom).unwrap();
assert_eq!(action, Action::Create);
}

#[test]
fn empty_list_as_create_action_rejected() {
let empty_list = [0xc0];
let action: Result<Action, DecoderError> = rlp::decode(&empty_list);
assert_eq!(action, Err(DecoderError::RlpExpectedToBeData));
}

#[test]
fn signing_eip155_zero_chainid() {
use ethkey::{Random, Generator};
Expand Down