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

Commit

Permalink
add more tx tests (#11038)
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian authored and s3krit committed Sep 12, 2019
1 parent 9051d19 commit a30cc89
Showing 1 changed file with 19 additions and 1 deletion.
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 @@ -566,6 +570,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

0 comments on commit a30cc89

Please sign in to comment.