package io.rudefox.burrow; import com.bjdweck.test.CliTestFixture; import org.junit.jupiter.api.Test; import java.io.UnsupportedEncodingException; import static org.junit.jupiter.api.Assertions.assertEquals; class mnemonic_command_tests extends CliTestFixture { @Test void with_arguments_interactive_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --interactive --dice6-entropy --bits 128"); expectedOutput("Input 50 dice rolls [1-6]: "); provideInput("234322343242422344161254151\r\n"); expectedOutput("Input 23 more dice rolls [1-6]: "); provideInput("33116265515343114314456\r\n"); expectedOutput("mountain tilt wing silk rude fox almost volume wine media verify card" + EOL); doMain(); verifyOutput(); } @Test void with_no_arguments_should_output_mnemonic() throws UnsupportedEncodingException { withArgs("mnemonic"); doMain(); assertEquals(24, getOutput().split(" ").length); } @Test void with_arguments_non_interactive_dice_bits_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --dice6-entropy --events 23432234324242234416125415133116265515343114314456 --bits 128"); expectedOutput("mountain tilt wing silk rude fox almost volume wine media verify card" + EOL); doMain(); verifyOutput(); } @Test void with_arguments_non_interactive_binary_entropy_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --binary-entropy --events 10100101010010101010101000101010101001010100101010101010001010101010010101001010101010100010101010100101010010101010101000101010 --bits 128"); expectedOutput("pipe fetch melt enhance primary best news fetch click clean pride feed" + EOL); doMain(); verifyOutput(); } @Test void with_arguments_without_interactive_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --dice6-entropy --events 2343223432424223441612541513311626551534311431445623432234324242234416125415133116265515343114314456"); expectedOutput("first welcome social broccoli nasty rather weird uncle spirit horn update pencil help rescue " + "grape enough fork wave eight fuel ribbon pony clean couple" + EOL); doMain(); verifyOutput(); } @Test void with_arguments_without_interactive_d8_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --dice8-entropy --events 23438688738737812541514768125415147632873218 --bits 128"); expectedOutput("fashion wave tourist notice alert marine vote alert marine vocal dish aware" + EOL); doMain(); verifyOutput(); } private void doMain() { setInput(); RudefoxBurrow.main(getArgs()); } }