<s> import copy <EOL> import unittest <EOL> from pycoin . encoding import EncodingError <EOL> from coloredcoinlib import ColorSet <EOL> from coloredcoinlib . tests . test_colorset import MockColorMap <EOL> from ngcccbase . address import InvalidAddressError <EOL> from ngcccbase . asset import AssetDefinition <EOL> from ngcccbase . deterministic import DWalletAddressManager <EOL> class TestDeterministic ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . colormap = MockColorMap ( ) <EOL> d = self . colormap . d <EOL> self . colorset0 = ColorSet ( self . colormap , [ '<STR_LIT>' ] ) <EOL> self . colorset1 = ColorSet ( self . colormap , [ d [ <NUM_LIT:1> ] ] ) <EOL> self . colorset1alt = ColorSet ( self . colormap , [ d [ <NUM_LIT:1> ] , d [ <NUM_LIT:6> ] ] ) <EOL> self . colorset2 = ColorSet ( self . colormap , [ d [ <NUM_LIT:2> ] ] ) <EOL> self . colorset3 = ColorSet ( self . colormap , [ d [ <NUM_LIT:3> ] , d [ <NUM_LIT:4> ] ] ) <EOL> self . def1 = { '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . colorset1 . get_data ( ) , <EOL> '<STR_LIT>' : <NUM_LIT:10> } <EOL> self . asset1 = AssetDefinition ( self . colormap , self . def1 ) <EOL> self . master_key = '<STR_LIT>' <EOL> self . privkey = '<STR_LIT>' <EOL> self . pubkey = '<STR_LIT>' <EOL> c = { <EOL> '<STR_LIT>' : self . master_key , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ self . colorset1 . get_data ( ) , <EOL> self . colorset2 . get_data ( ) ] , <EOL> '<STR_LIT>' : [ <EOL> { '<STR_LIT>' : self . colorset0 . get_data ( ) , "<STR_LIT>" : <NUM_LIT:0> } , <EOL> { '<STR_LIT>' : self . colorset1 . get_data ( ) , "<STR_LIT>" : <NUM_LIT:3> } , <EOL> { '<STR_LIT>' : self . colorset2 . get_data ( ) , "<STR_LIT>" : <NUM_LIT:2> } , <EOL> ] , <EOL> } , <EOL> '<STR_LIT>' : [ { '<STR_LIT>' : self . privkey , <EOL> '<STR_LIT>' : self . colorset1 . get_data ( ) , <EOL> } ] , <EOL> '<STR_LIT>' : False , <EOL> } <EOL> self . config = copy . deepcopy ( c ) <EOL> self . maindwam = DWalletAddressManager ( self . colormap , c ) <EOL> def test_init_new_wallet ( self ) : <EOL> c = copy . deepcopy ( self . config ) <EOL> del c [ '<STR_LIT>' ] <EOL> del c [ '<STR_LIT>' ] <EOL> newdwam = DWalletAddressManager ( self . colormap , c ) <EOL> params = newdwam . init_new_wallet ( ) <EOL> self . assertNotEqual ( self . config [ '<STR_LIT>' ] , <EOL> newdwam . config [ '<STR_LIT>' ] ) <EOL> c = copy . deepcopy ( self . config ) <EOL> c [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertRaises ( EncodingError , DWalletAddressManager , <EOL> self . colormap , c ) <EOL> def test_get_new_address ( self ) : <EOL> self . assertEqual ( self . maindwam . get_new_address ( self . colorset2 ) . index , <EOL> <NUM_LIT:3> ) <EOL> self . assertEqual ( self . maindwam . get_new_address ( self . asset1 ) . index , <EOL> <NUM_LIT:4> ) <EOL> def test_get_new_genesis_address ( self ) : <EOL> addr = self . maindwam . get_new_genesis_address ( ) <EOL> self . assertEqual ( addr . index , <NUM_LIT:2> ) <EOL> addr2 = self . maindwam . get_new_address ( addr . get_color_set ( ) ) <EOL> self . assertEqual ( addr2 . index , <NUM_LIT:0> ) <EOL> def test_get_update_genesis_address ( self ) : <EOL> addr = self . maindwam . get_genesis_address ( <NUM_LIT:0> ) <EOL> self . maindwam . update_genesis_address ( addr , self . colorset1alt ) <EOL> self . assertEqual ( addr . get_color_set ( ) , self . colorset1alt ) <EOL> def test_get_change_address ( self ) : <EOL> addr = self . maindwam . get_change_address ( self . colorset0 ) <EOL> self . assertEqual ( addr . get_color_set ( ) . __repr__ ( ) , <EOL> self . colorset0 . __repr__ ( ) ) <EOL> self . assertEqual ( self . maindwam . get_change_address ( self . colorset3 ) . index , <EOL> <NUM_LIT:0> ) <EOL> def test_get_all_addresses ( self ) : <EOL> addrs = [ a . get_address ( ) for a in self . maindwam . get_all_addresses ( ) ] <EOL> self . assertTrue ( self . pubkey in addrs ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
