def setUp(self): super(GetNewAddressesCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetNewAddressesCommand(self.adapter) self.seed =\ Seed( b'TESTVALUE9DONTUSEINPRODUCTION99999ZDCCUF' b'CBBIQCLGMEXAVFQEOF9DRAB9VCEBAGXAF9VF9FLHP', ) self.addy_1 =\ Address( b'NYMWLBUJEISSACZZBRENC9HEHYQXHCGQHSNHVCEA' b'ZDCTEVNGSDUEKTSYBSQGMVJRIEDHWDYSEYCFAZAH9', ) self.addy_2 =\ Address( b'NTPSEVZHQITARYWHIRTSIFSERINLRYVXLGIQKKHY' b'IWYTLQUUHDWSOVXLIKVJTYZBFKLABWRBFYVSMD9NB', ) self.addy_1_checksum =\ Address( b'NYMWLBUJEISSACZZBRENC9HEHYQXHCGQHSNHVCEA' b'ZDCTEVNGSDUEKTSYBSQGMVJRIEDHWDYSEYCFAZAH' b'9T9FPJROTW', )
def test_routing(self): """ Routing commands to different adapters. """ default_adapter = MockAdapter() pow_adapter = MockAdapter() wrapper = ( RoutingWrapper(default_adapter) .add_route('attachToTangle', pow_adapter) .add_route('interruptAttachingToTangle', pow_adapter) ) default_adapter.seed_response('getNodeInfo', {'id': 'default1'}) pow_adapter.seed_response('attachToTangle', {'id': 'pow1'}) pow_adapter.seed_response('interruptAttachingToTangle', {'id': 'pow2'}) self.assertDictEqual( wrapper.send_request({'command': 'attachToTangle'}), {'id': 'pow1'}, ) self.assertDictEqual( wrapper.send_request({'command': 'interruptAttachingToTangle'}), {'id': 'pow2'}, ) # Any commands that aren't routed go to the default adapter. self.assertDictEqual( wrapper.send_request({'command': 'getNodeInfo'}), {'id': 'default1'}, )
def setUp(self): super(GetInputsCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetInputsCommand(self.adapter) # Define some valid tryte sequences that we can reuse between # tests. self.addy0 =\ Address( trytes = b'TESTVALUE9DONTUSEINPRODUCTION99999FIODSG' b'IC9CCIFCNBTBDFIEHHE9RBAEVGK9JECCLCPBIINAX', key_index = 0, ) self.addy1 =\ Address( trytes = b'TESTVALUE9DONTUSEINPRODUCTION999999EPCNH' b'MBTEH9KDVFMHHESDOBTFFACCGBFGACEDCDDCGICIL', key_index = 1, ) self.addy2 =\ Address( trytes = b'TESTVALUE9DONTUSEINPRODUCTION99999YDOHWF' b'U9PFOFHGKFACCCBGDALGI9ZBEBABFAMBPDSEQ9XHJ', key_index = 2, )
def setUp(self): super(BroadcastAndStoreCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = BroadcastAndStoreCommand(self.adapter) # Define a few valid values that we can reuse across tests. self.trytes1 = b'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ b'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA'
def setUp(self): super(PromoteTransactionCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = PromoteTransactionCommand(self.adapter) self.trytes1 = b'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ b'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA' self.hash1 = TransactionHash( b'TESTVALUE9DONTUSEINPRODUCTION99999TBPDM9' b'ADFAWCKCSFUALFGETFIFG9UHIEFE9AYESEHDUBDDF')
class GetBalancesResponseFilterTestCase(BaseFilterTestCase): filter_type = GetBalancesCommand(MockAdapter()).get_response_filter skip_value_check = True def test_balances(self): """ Typical ``getBalances`` response. """ filter_ = self._filter({ 'balances': ['114544444', '0', '8175737'], 'duration': 42, 'milestoneIndex': 128, 'milestone': 'INRTUYSZCWBHGFGGXXPWRWBZACYAFGVRRP9VYEQJ' 'OHYD9URMELKWAFYFMNTSP9MCHLXRGAFMBOZPZ9999', }) self.assertFilterPasses(filter_) self.assertDictEqual( filter_.cleaned_data, { 'balances': [114544444, 0, 8175737], 'duration': 42, 'milestoneIndex': 128, 'milestone': Address( b'INRTUYSZCWBHGFGGXXPWRWBZACYAFGVRRP9VYEQJ' b'OHYD9URMELKWAFYFMNTSP9MCHLXRGAFMBOZPZ9999', ), }, )
class GetNeighborsRequestFilterTestCase(BaseFilterTestCase): filter_type = GetNeighborsCommand(MockAdapter()).get_request_filter skip_value_check = True def test_pass_empty(self): """ The request is (correctly) empty. """ filter_ = self._filter({}) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, {}) def test_fail_unexpected_parameters(self): """ The request contains unexpected parameters. """ self.assertFilterErrors( { # Fool of a Took! 'foo': 'bar', }, { 'foo': [f.FilterMapper.CODE_EXTRA_KEY], }, )
def setUp(self): super(SendTrytesCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = SendTrytesCommand(self.adapter) # Define a few valid values that we can reuse across tests. self.trytes1 = b'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ b'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA' self.transaction1 = (b'TKGDZ9GEI9CPNQGHEATIISAKYPPPSXVCXBSR9EIW' b'CTHHSSEQCD9YLDPEXYERCNJVASRGWMAVKFQTC9999') self.transaction2 = (b'TKGDZ9GEI9CPNQGHEATIISAKYPPPSXVCXBSR9EIW' b'CTHHSSEQCD9YLDPEXYERCNJVASRGWMAVKFQTC9999')
def setUp(self): super(CreateMultisigAddressCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = CreateMultisigAddressCommand(self.adapter) # Define some tryte sequences that we can reuse between tests. self.digest_1 =\ Digest( trytes = b'FWNEPVJNGUKTSHSBDO9AORBCVWWLVXC9KAMKYYNKPYNJDKSAUURI9ELKOEEYPKVTYP' b'CKOCJQESYFEMINIFKX9PDDGRBEEHYYXCJW9LHGWFZGHKCPVDBGMGQKIPCNKNITGMZT' b'DIWVUB9PCHCOPHMIWKSUKRHZOJPMAY', key_index = 0, ) self.digest_2 =\ Digest( trytes = b'PAIRLDJQY9XAUSKIGCTHRJHZVARBEY9NNHYJ9UI9HWWZXFSDWEZEGDCWNVVYSYDV9O' b'HTR9NGGZURISWTNECFTCMEWQQFJ9VKLFPDTYJYXC99OLGRH9OSFJLMEOGHFDHZYEAF' b'IMIZTJRBQUVCR9U9ZWTMUXTUEOUBLC', key_index = 0, )
class FindTransactionsResponseFilterTestCase(BaseFilterTestCase): filter_type = FindTransactionsCommand(MockAdapter()).get_response_filter skip_value_check = True # noinspection SpellCheckingInspection def setUp(self): super(FindTransactionsResponseFilterTestCase, self).setUp() # Define a few valid values here that we can reuse across multiple # tests. self.trytes1 = b'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ b'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA' def test_no_results(self): """ The incoming response contains no hashes. """ response = { 'hashes': [], 'duration': 42, } filter_ = self._filter(response) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, response) # noinspection SpellCheckingInspection def test_search_results(self): """ The incoming response contains lots of hashes. """ filter_ = self._filter({ 'hashes': [ 'RVORZ9SIIP9RCYMREUIXXVPQIPHVCNPQ9HZWYKFW' 'YWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVA', 'ZJVYUGTDRPDYFGFXMKOTV9ZWSGFK9CFPXTITQLQN' 'LPPG9YNAARMKNKYQO9GSCSBIOTGMLJUFLZWSY9999', ], 'duration': 42, }) self.assertFilterPasses(filter_) self.assertDictEqual( filter_.cleaned_data, { 'hashes': [ TransactionHash( b'RVORZ9SIIP9RCYMREUIXXVPQIPHVCNPQ9HZWYKFW' b'YWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVA', ), TransactionHash( b'ZJVYUGTDRPDYFGFXMKOTV9ZWSGFK9CFPXTITQLQN' b'LPPG9YNAARMKNKYQO9GSCSBIOTGMLJUFLZWSY9999', ), ], 'duration': 42, }, )
def setUp(self): super(GetAccountDataCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetAccountDataCommand(self.adapter) # Define some tryte sequences we can re-use between tests. self.addy1 =\ Address( b'TESTVALUEONE9DONTUSEINPRODUCTION99999YDZ' b'E9TAFAJGJA9CECKDAEPHBICDR9LHFCOFRBQDHC9IG', key_index = 0, ) self.addy2 =\ Address( b'TESTVALUETWO9DONTUSEINPRODUCTION99999TES' b'GINEIDLEEHRAOGEBMDLENFDAFCHEIHZ9EBZDD9YHL', key_index = 1, ) self.hash1 =\ TransactionHash( b'TESTVALUE9DONTUSEINPRODUCTION99999O99IDB' b'MBPAPDXBSDWAMHV9DASEGCOGHBV9VAF9UGRHFDPFJ' ) self.hash2 =\ TransactionHash( b'TESTVALUE9DONTUSEINPRODUCTION99999OCNCHC' b'TEPBHEPBJEWFXERHSCQCH9TAAANDBBCCHCIDEAVBV' )
class GetNodeInfoRequestFilterTestCase(BaseFilterTestCase): filter_type = GetNodeInfoCommand(MockAdapter()).get_request_filter skip_value_check = True def test_pass_empty(self): """ The incoming response is (correctly) empty. """ request = {} filter_ = self._filter(request) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, request) def test_fail_unexpected_parameters(self): """ The incoming response contains unexpected parameters. """ self.assertFilterErrors( { # All you had to do was nothing! How did you screw that up?! 'foo': 'bar', }, { 'foo': [f.FilterMapper.CODE_EXTRA_KEY], }, )
def setUp(self): super(HelpersTestCase, self).setUp() self.api = api = Iota('mock://') self.api.adapter = MockAdapter() # noinspection SpellCheckingInspection self.transaction = ('TESTVALUE9DONTUSEINPRODUCTION99999KPZOTR' 'VDB9GZDJGZSSDCBIX9QOK9PAV9RMDBGDXLDTIZTWQ')
def test_unregistered_command(self): """ Attempting to create an unsupported command. """ api = StrictIota(MockAdapter()) with self.assertRaises(InvalidCommand): # noinspection PyStatementEffect api.helloWorld
def setUp(self): super(GetTransfersCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetTransfersCommand(self.adapter) # Define some tryte sequences we can re-use between tests. self.addy1 =\ Address( b'TESTVALUEONE9DONTUSEINPRODUCTION99999YDZ' b'E9TAFAJGJA9CECKDAEPHBICDR9LHFCOFRBQDHC9IG' ) self.addy2 =\ Address( b'TESTVALUETWO9DONTUSEINPRODUCTION99999TES' b'GINEIDLEEHRAOGEBMDLENFDAFCHEIHZ9EBZDD9YHL' )
class BroadcastAndStoreCommandTestCase(TestCase): # noinspection SpellCheckingInspection def setUp(self): super(BroadcastAndStoreCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = BroadcastAndStoreCommand(self.adapter) # Define a few valid values that we can reuse across tests. self.trytes1 = b'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ b'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA' def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).broadcastAndStore, BroadcastAndStoreCommand, ) def test_happy_path(self): """ Successful invocation of ``broadcastAndStore``. """ self.adapter.seed_response( 'broadcastTransactions', { 'trytes': [ text_type(self.trytes1, 'ascii'), text_type(self.trytes2, 'ascii'), ], }) self.adapter.seed_response('storeTransactions', {}) trytes = [ TransactionTrytes(self.trytes1), TransactionTrytes(self.trytes2), ] response = self.command(trytes=trytes) self.assertDictEqual(response, {'trytes': trytes})
def test_registered_command(self): """ Preparing a documented command. """ api = StrictIota(MockAdapter()) # We just need to make sure the correct command type is # instantiated; individual commands have their own unit tests. command = api.getNodeInfo self.assertIsInstance(command, GetNodeInfoCommand)
def test_create_command(self): """ Preparing an experimental/undocumented command. """ api = StrictIota(MockAdapter()) custom_command = api.create_command('helloWorld') self.assertIsInstance(custom_command, CustomCommand) self.assertEqual(custom_command.command, 'helloWorld')
class GetTrytesResponseFilter(BaseFilterTestCase): filter_type = GetTrytesCommand(MockAdapter()).get_response_filter skip_value_check = True # noinspection SpellCheckingInspection def setUp(self): super(GetTrytesResponseFilter, self).setUp() # Define some valid tryte sequences that we can re-use between # tests. self.trytes1 = 'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ 'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA' def test_pass_transactions(self): """ The response contains data for multiple transactions. """ filter_ = self._filter({ 'trytes': [ # In real life, these values would be a lot longer, but for the # purposes of this test, any sequence of trytes will do. self.trytes1, self.trytes2, ], 'duration': 42, }) self.assertFilterPasses(filter_) self.assertDictEqual( filter_.cleaned_data, { 'trytes': [ TryteString(self.trytes1), TryteString(self.trytes2), ], 'duration': 42, }, ) def test_pass_no_transactions(self): """ The response does not contain any transactions. """ response = { 'trytes': [], 'duration': 42, } filter_ = self._filter(response) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, response)
def setUp(self): super(PrepareMultisigTransferCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = PrepareMultisigTransferCommand(self.adapter) # Define some tryte sequences that we can reuse between tests. self.digest_1 =\ Digest( trytes = b'FWNEPVJNGUKTSHSBDO9AORBCVWWLVXC9KAMKYYNKPYNJDKSAUURI9ELKOEEYPKVTYP' b'CKOCJQESYFEMINIFKX9PDDGRBEEHYYXCJW9LHGWFZGHKCPVDBGMGQKIPCNKNITGMZT' b'DIWVUB9PCHCOPHMIWKSUKRHZOJPMAY', key_index = 0, ) self.digest_2 =\ Digest( trytes = b'PAIRLDJQY9XAUSKIGCTHRJHZVARBEY9NNHYJ9UI9HWWZXFSDWEZEGDCWNVVYSYDV9O' b'HTR9NGGZURISWTNECFTCMEWQQFJ9VKLFPDTYJYXC99OLGRH9OSFJLMEOGHFDHZYEAF' b'IMIZTJRBQUVCR9U9ZWTMUXTUEOUBLC', key_index = 0, ) self.trytes_1 = ( b'TESTVALUE9DONTUSEINPRODUCTION99999IIPEM9' b'LA9FLHEGHDACSA9DOBQHQCX9BBHCFDIIMACARHA9B' ) self.trytes_2 = ( b'TESTVALUE9DONTUSEINPRODUCTION99999BGUDVE' b'DGH9WFQDEDVETCOGEGCDI9RFHGFGXBI99EJICHNEM' ) self.trytes_3 = ( b'TESTVALUE9DONTUSEINPRODUCTION99999XBGEUC' b'LF9EIFXHM9KHQANBLBHFVGTEGBWHNAKFDGZHYGCHI' )
def setUp(self): super(GetDigestsCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetDigestsCommand(self.adapter) # Define some tryte sequences that we can reuse between tests. self.key1 = PrivateKey(TryteString(b'KEYONE', pad=FRAGMENT_LENGTH), 0) self.key2 = PrivateKey(TryteString(b'KEYTWO', pad=FRAGMENT_LENGTH), 1) self.digest1 = Digest(TryteString(b'DIGESTONE', pad=Hash.LEN), 0) self.digest2 = Digest(TryteString(b'DIGESTTWO', pad=Hash.LEN), 1)
class GetTipsCommandTestCase(TestCase): def setUp(self): super(GetTipsCommandTestCase, self).setUp() self.adapter = MockAdapter() def test_wireup(self): """ Verify that the command is wired up correctly. """ self.assertIsInstance( Iota(self.adapter).getTips, GetTipsCommand, ) def test_type_coercion(self): """ The result is coerced to the proper type. https://github.com/iotaledger/iota.lib.py/issues/130 """ # noinspection SpellCheckingInspection self.adapter.seed_response( 'getTips', { 'duration': 42, 'hashes': [ 'TESTVALUE9DONTUSEINPRODUCTION99999ANSVWB' 'CZ9ABZYUK9YYXFRLROGMCMQHRARDQPNMHHZSZ9999', 'TESTVALUE9DONTUSEINPRODUCTION99999HCZURL' 'NFWEDRFCYHWTYGUEMJLJ9ZIJTFASAVSEAZJGA9999', ], }) gt_response = Iota(self.adapter).get_tips() self.assertEqual( list(map(type, gt_response['hashes'])), [TransactionHash] * 2, )
class GetTipsResponseFilterTestCase(BaseFilterTestCase): filter_type = GetTipsCommand(MockAdapter()).get_response_filter skip_value_check = True # noinspection SpellCheckingInspection def test_pass_lots_of_hashes(self): """ The response contains lots of hashes. """ response = { 'hashes': [ 'YVXJOEOP9JEPRQUVBPJMB9MGIB9OMTIJJLIUYPM9' 'YBIWXPZ9PQCCGXYSLKQWKHBRVA9AKKKXXMXF99999', 'ZUMARCWKZOZRMJM9EEYJQCGXLHWXPRTMNWPBRCAG' 'SGQNRHKGRUCIYQDAEUUEBRDBNBYHAQSSFZZQW9999', 'QLQECHDVQBMXKD9YYLBMGQLLIQ9PSOVDRLYCLLFM' 'S9O99XIKCUHWAFWSTARYNCPAVIQIBTVJROOYZ9999', ], 'duration': 4 } filter_ = self._filter(response) self.assertFilterPasses(filter_) self.assertDictEqual( filter_.cleaned_data, { 'hashes': [ Address(b'YVXJOEOP9JEPRQUVBPJMB9MGIB9OMTIJJLIUYPM9' b'YBIWXPZ9PQCCGXYSLKQWKHBRVA9AKKKXXMXF99999'), Address(b'ZUMARCWKZOZRMJM9EEYJQCGXLHWXPRTMNWPBRCAG' b'SGQNRHKGRUCIYQDAEUUEBRDBNBYHAQSSFZZQW9999'), Address(b'QLQECHDVQBMXKD9YYLBMGQLLIQ9PSOVDRLYCLLFM' b'S9O99XIKCUHWAFWSTARYNCPAVIQIBTVJROOYZ9999'), ], 'duration': 4, }) def test_pass_no_hashes(self): """ The response doesn't contain any hashes. """ response = { 'hashes': [], 'duration': 4, } filter_ = self._filter(response) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, response)
class IsReattachableResponseFilterTestCase(BaseFilterTestCase): filter_type = IsReattachableCommand(MockAdapter()).get_response_filter skip_value_check = True # noinspection SpellCheckingInspection def setUp(self): super(IsReattachableResponseFilterTestCase, self).setUp() # Define a few valid values that we can reuse across tests. self.addresses_1 = ('TESTVALUE9DONTUSEINPRODUCTION99999EKJZZT' 'SOGJOUNVEWLDPKGTGAOIZIPMGBLHC9LMQNHLGXGYX') def test_pass_happy_path(self): """ Typical ``IsReattachable`` request. """ response = {'reattachable': [True, False]} filter_ = self._filter(response) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, response) def test_fail_empty(self): """ The incoming response is empty. """ self.assertFilterErrors( {}, { 'reattachable': [f.Required.CODE_EMPTY], }, ) def test_pass_incompatible_types(self): """ The response contains values that can NOT be converted to the expected types. """ request = { 'reattachable': [1234234, b'', 'test'], } self.assertFilterErrors( request, { 'reattachable.0': [f.Type.CODE_WRONG_TYPE], 'reattachable.1': [f.Type.CODE_WRONG_TYPE], 'reattachable.2': [f.Type.CODE_WRONG_TYPE] }, )
def setUp(self): super(GetLatestInclusionCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetLatestInclusionCommand(self.adapter) # Define some tryte sequences that we can re-use across tests. self.milestone =\ TransactionHash( b'TESTVALUE9DONTUSEINPRODUCTION99999W9KDIH' b'BALAYAFCADIDU9HCXDKIXEYDNFRAKHN9IEIDZFWGJ' ) self.hash1 =\ TransactionHash( b'TESTVALUE9DONTUSEINPRODUCTION99999TBPDM9' b'ADFAWCKCSFUALFGETFIFG9UHIEFE9AYESEHDUBDDF' ) self.hash2 =\ TransactionHash( b'TESTVALUE9DONTUSEINPRODUCTION99999CIGCCF' b'KIUFZF9EP9YEYGQAIEXDTEAAUGAEWBBASHYCWBHDX' )
def setUp(self): super(GetPrivateKeysCommandTestCase, self).setUp() self.adapter = MockAdapter() self.command = GetPrivateKeysCommand(self.adapter) # # Create a few tryte sequences we can reuse across tests. # # Note that these are not realistic values for private keys (a real # private key's length is a multiple of 2187 trytes), but we're # going to mock the KeyGenerator functionality anyway, so we just # need something that's short enough to be easy to compare. # self.trytes1 = TryteString(b'KEYONE', pad=FRAGMENT_LENGTH) self.trytes2 = TryteString(b'KEYTWO', pad=FRAGMENT_LENGTH)
class GetTransactionsToApproveResponseFilterTestCase(BaseFilterTestCase): filter_type =\ GetTransactionsToApproveCommand(MockAdapter()).get_response_filter skip_value_check = True # noinspection SpellCheckingInspection def test_pass_happy_path(self): """ Typical ``getTransactionsToApprove`` response. """ response = { 'trunkTransaction': 'TKGDZ9GEI9CPNQGHEATIISAKYPPPSXVCXBSR9EIW' 'CTHHSSEQCD9YLDPEXYERCNJVASRGWMAVKFQTC9999', 'branchTransaction': 'TKGDZ9GEI9CPNQGHEATIISAKYPPPSXVCXBSR9EIW' 'CTHHSSEQCD9YLDPEXYERCNJVASRGWMAVKFQTC9999', 'duration': 936, } filter_ = self._filter(response) self.assertFilterPasses(filter_) self.assertDictEqual( filter_.cleaned_data, { 'trunkTransaction': TransactionHash( b'TKGDZ9GEI9CPNQGHEATIISAKYPPPSXVCXBSR9EIW' b'CTHHSSEQCD9YLDPEXYERCNJVASRGWMAVKFQTC9999' ), 'branchTransaction': TransactionHash( b'TKGDZ9GEI9CPNQGHEATIISAKYPPPSXVCXBSR9EIW' b'CTHHSSEQCD9YLDPEXYERCNJVASRGWMAVKFQTC9999' ), 'duration': 936, }, )
class AttachToTangleResponseFilterTestCase(BaseFilterTestCase): filter_type = AttachToTangleCommand(MockAdapter()).get_response_filter skip_value_check = True # noinspection SpellCheckingInspection def setUp(self): super(AttachToTangleResponseFilterTestCase, self).setUp() # Define a few valid values here that we can reuse across multiple # tests. self.trytes1 = 'RBTC9D9DCDQAEASBYBCCKBFA' self.trytes2 =\ 'CCPCBDVC9DTCEAKDXC9D9DEARCWCPCBDVCTCEAHDWCTCEAKDCDFD9DSCSA' def test_pass_happy_path(self): """ The incoming response contains valid values. """ filter_ = self._filter({ # Trytes arrive from the node as strings. 'trytes': [ self.trytes1, self.trytes2, ], 'duration': 42, }) self.assertFilterPasses(filter_) self.assertDictEqual( filter_.cleaned_data, { 'trytes': [ TransactionTrytes(self.trytes1), TransactionTrytes(self.trytes2), ], 'duration': 42, }, )
class InterruptAttachingToTangleRequestFilterTestCase(BaseFilterTestCase): filter_type =\ InterruptAttachingToTangleCommand(MockAdapter()).get_request_filter skip_value_check = True def test_pass_empty(self): filter_ = self._filter({}) self.assertFilterPasses(filter_) self.assertDictEqual(filter_.cleaned_data, {}) def test_fail_unexpected_parameters(self): """ The request contains unexpected parameters. """ self.assertFilterErrors( { # You're tearing me apart Lisa! 'foo': 'bar', }, { 'foo': [f.FilterMapper.CODE_EXTRA_KEY], }, )
def setUp(self): super(WereAddressesSpentFromCommandTestCase, self).setUp() self.adapter = MockAdapter()