<commit_before>from utils import common
from TestCase.MVSTestCase import *

class TestDIDBatch(MVSTestCaseBase):
    def test_0_issuedid_batch(self):
        # create 5000 account
        # send 1 etp to each account
        # issue a did for each account
        now = common.get_timestamp()

        def get_account_name(i, j):
            return "Account_%s_%s" % (i, j)
        def get_did_symbol(i, j):
            return "tempdid_%s_%s.%s" % (i, j, now)

        lastwords = []
        addresses = []

        batch_amount_i, batch_amount_j = 500, 10 # total 5000

        def get_lastword(i, j):
            return lastwords[i * batch_amount_j + j]

        def get_address(i, j):
            return addresses[i * batch_amount_j + j]

        def get_did_count():
            ec, message = mvs_rpc.list_dids()
            self.assertEqual(ec, 0)
            return len(message["dids"])

        for i in xrange(batch_amount_i):
            receivers = {}
            for j in xrange(batch_amount_j):
                ec, (lastword, address) = mvs_rpc.easy_new_account(get_account_name(i, j), "123456")
                self.assertEqual(ec, 0)
                lastwords.append(lastword)
                addresses.append( address )

                receivers[address] = 10**8 # 1 etp for each
            Alice.sendmore_etp(receivers)
            Alice.mining()
        try:
            previous = get_did_count()
            for i in xrange(batch_amount_i):
                for j in xrange(batch_amount_j):
                    ec, message = mvs_rpc.issue_did(get_account_name(i, j), "123456", get_address(i, j), get_did_symbol(i, j))
                    self.assertEqual(ec, 0)

            current = 0
            mine_round = 0
            while current < previous + batch_amount_i*batch_amount_j:
                Alice.mining()
                current = get_did_count()
                mine_round += 1

            self.assertEqual(mine_round, 3) # 2000 txs for 1 block, 5000 did ~~ 2.5 block, mine 3 times

        finally:
            for i in xrange(batch_amount_i):
                for j in xrange(batch_amount_j):
                    ec, message = mvs_rpc.delete_account(get_account_name(i, j), "123456", get_lastword(i, j))
                    self.assertEqual(ec, 0, message)<commit_msg>add batch test for issue did<commit_after>from utils import common
from TestCase.MVSTestCase import *

class TestDIDBatch(MVSTestCaseBase):
    def test_0_issuedid_batch(self):
        # create 5000 account
        # send 1 etp to each account
        # issue a did for each account
        now = common.get_timestamp()

        def get_account_name(i, j):
            return "Account_%s_%s" % (i, j)
        def get_did_symbol(i, j):
            return "tempdid_%s_%s.%s" % (i, j, now)

        lastwords = []
        addresses = []

        batch_amount_i, batch_amount_j = 200, 10 # total 2000

        def get_lastword(i, j):
            return lastwords[i * batch_amount_j + j]

        def get_address(i, j):
            return addresses[i * batch_amount_j + j]

        def get_did_count():
            ec, message = mvs_rpc.list_dids()
            self.assertEqual(ec, 0)
            return len(message["dids"])

        try:
            for i in xrange(batch_amount_i):
                receivers = {}
                for j in xrange(batch_amount_j):
                    ec, (lastword, address) = mvs_rpc.easy_new_account(get_account_name(i, j), "123456")
                    self.assertEqual(ec, 0)
                    lastwords.append(lastword)
                    addresses.append( address )

                    receivers[address] = 10**8 # 1 etp for each
                Alice.sendmore_etp(receivers)
                Alice.mining()

            previous = get_did_count()
            for i in xrange(batch_amount_i):
                for j in xrange(batch_amount_j):
                    ec, message = mvs_rpc.issue_did(get_account_name(i, j), "123456", get_address(i, j), get_did_symbol(i, j))
                    self.assertEqual(ec, 0)

            current = 0
            mine_round = 0
            while current < previous + batch_amount_i*batch_amount_j:
                Alice.mining()
                current = get_did_count()
                mine_round += 1

            self.assertEqual(mine_round, 2)

        finally:
            for i in xrange(batch_amount_i):
                for j in xrange(batch_amount_j):
                    ec, message = mvs_rpc.delete_account(get_account_name(i, j), "123456", get_lastword(i, j))
                    self.assertEqual(ec, 0, message)
{'fraction_non_alphanumeric': 0.09351892127011745, 'fraction_numerical': 0.02218355806872553, 'mean_word_length': 1.7704819277108435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7049610', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1372, 'n_words': 332}