|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +from dpos_test import ChainApi |
| 4 | + |
| 5 | +bubi_url = 'http://127.0.0.1:19333' |
| 6 | +keypair = './keypairs' |
| 7 | +mw_keypair = './mwkeypairs' |
| 8 | + |
| 9 | +genesis_account = 'a0015544fbf3e4038d9e752c3236b5185f5d98eb56049a' |
| 10 | +genesis_priv_key = 'c00109c8d07d81f3b4297f54bf85c0ce57ea5d8c37e48b8be723cfd64d0f63f363138c' |
| 11 | + |
| 12 | +class PrivacyTest(ChainApi): |
| 13 | + ''' Do mimblewimble function test ''' |
| 14 | + |
| 15 | + def __init__(self): |
| 16 | + ChainApi.__init__(url = bubi_url) |
| 17 | + |
| 18 | + def createMwKeyPair(self, output): |
| 19 | + self.genKeyPairs(10, output=mw_keypair) |
| 20 | + |
| 21 | + if not os.path.exists(output): |
| 22 | + os.mknod(output) |
| 23 | + elif not append: |
| 24 | + backup = output + '.bak' |
| 25 | + if os.path.exists(backup): |
| 26 | + os.remove(backup) |
| 27 | + if os.path.exists(output): |
| 28 | + os.rename(output, backup) |
| 29 | + os.mknod(output) |
| 30 | + |
| 31 | + with open(output, 'r+') as f: |
| 32 | + for i in xrange(number): |
| 33 | + res = self.req('createMwKeyPair', {}) |
| 34 | + if not res: |
| 35 | + return False, 'Failed to generate keypair' |
| 36 | + else: |
| 37 | + account = {} |
| 38 | + account['priv_key'] = res['result']['priv_key'] |
| 39 | + account['pub_key'] = res['result']['pub_key'] |
| 40 | + f.seek(0, 2) |
| 41 | + f.write(json.dumps(account) + '\n') |
| 42 | + if debug: |
| 43 | + logger.info('Generate %s keypairs done in %.2f second' % (number, (time.time() - start))) |
| 44 | + return True, '' |
| 45 | + |
| 46 | + def createMwTx(self): |
| 47 | + |
| 48 | + def issue(self): |
| 49 | + |
| 50 | + def initMw(self): |
| 51 | + |
| 52 | + acc_list = [] |
| 53 | + payload = {'items': []} |
| 54 | + n = self.newNonce(genesis_account) |
| 55 | + with open(keypair, 'r') as f: |
| 56 | + acc_list = [json.loads(l.strip()) for l in f.readlines()] |
| 57 | + |
| 58 | + self.addPayload(payload, 'create_account', acc_list, nonce=n) |
| 59 | + |
| 60 | + res, msg = self.createContract() |
| 61 | + if not res: |
| 62 | + return False, msg |
| 63 | + |
| 64 | + res, msg = self.issue() |
| 65 | + if not res: |
| 66 | + return False, msg |
| 67 | + |
| 68 | + res, msg = self.addressMapping() |
| 69 | + if not res: |
| 70 | + return False, msg |
| 71 | + |
| 72 | + |
| 73 | + def transfer(self): |
| 74 | + |
| 75 | + def addressMapping(self): |
| 76 | + |
| 77 | + def getAccountInfo(self): |
| 78 | + |
| 79 | + |
0 commit comments