From 78f9c092786cdacafcabf3e40ed58cf1d3927cad Mon Sep 17 00:00:00 2001 From: pinkiebell <40266861+pinkiebell@users.noreply.github.com> Date: Sun, 21 Oct 2018 13:01:00 +0200 Subject: [PATCH] beacon_chain/utils/shuffling: Resolve PR comments --- beacon_chain/utils/shuffling/src/lib.rs | 7 +--- .../src/specs/shuffle_test_vectors.yaml | 38 +------------------ 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/beacon_chain/utils/shuffling/src/lib.rs b/beacon_chain/utils/shuffling/src/lib.rs index 9623a1fdc..91a3a73e2 100644 --- a/beacon_chain/utils/shuffling/src/lib.rs +++ b/beacon_chain/utils/shuffling/src/lib.rs @@ -30,7 +30,7 @@ pub fn shuffle( return Err(ShuffleErr::ExceedsListLength); } - if list.len() == 0 { + if list.is_empty() { return Ok(list); } @@ -78,10 +78,7 @@ mod tests { let mut s = shuffle(&seed, input).unwrap(); - assert_eq!( - s, - output, - ); + assert_eq!(s, output); } } } diff --git a/beacon_chain/utils/shuffling/src/specs/shuffle_test_vectors.yaml b/beacon_chain/utils/shuffling/src/specs/shuffle_test_vectors.yaml index c75b6aeaa..c97d6d328 100644 --- a/beacon_chain/utils/shuffling/src/specs/shuffle_test_vectors.yaml +++ b/beacon_chain/utils/shuffling/src/specs/shuffle_test_vectors.yaml @@ -1,41 +1,5 @@ -# This file was generated with a modified version of shuffling_sandbox +# This file was generated with sigp/shuffling_sandbox # python3 sandbox.py test_vectors -#diff --git a/sandbox.py b/sandbox.py -#index 99b0ba7..cd7cafe 100644 -#--- a/sandbox.py -#+++ b/sandbox.py -#@@ -126,13 +126,13 @@ elif args.method == "test_vectors": -# results = [] -# -# seeds = [ -#- b"", -#- blake("4kn4driuctg8".encode()), # known to cause conflicts with old shuffler -#- blake("ytre1p".encode()), -#- blake("mytobcffnkvj".encode()), -#- blake("myzu3g7evxp5nkvj".encode()), -#- blake("xdpli1jsx5xb".encode()), -#- blake("oab3mbb3xe8qsx5xb".encode()), -#+ "", -#+ "4kn4driuctg8", # known to cause conflicts with old shuffler -#+ "ytre1p", -#+ "mytobcffnkvj", -#+ "myzu3g7evxp5nkvj", -#+ "xdpli1jsx5xb", -#+ "oab3mbb3xe8qsx5xb", -# ] -# lists = [ -# [], -#@@ -147,7 +147,8 @@ elif args.method == "test_vectors": -# -# for seed in seeds: -# for lst in lists: -#- output = shuffler(lst, seed) -#+ blake_seed = blake(seed.encode()) if len(seed) > 0 else b"" -#+ output = shuffler(lst, blake_seed) -# results.append({"seed": seed, "input": lst, "output": output}) -# -# body = { - title: Shuffling Algorithm Tests summary: Test vectors for shuffling a list based upon a seed. test_suite: Shuffling