def create_block( l1_headers: "L1Headers", ddss: Union[str, float, int], valid_block_count: int, regions: List[str], clouds: List[str], l2_blocks: Iterable["l2_block_model.L2BlockModel"], ) -> l3_block_model.L3BlockModel: block_id, prev_proof = get_next_block_info() # Pull configuration from matchmaking directly to get DDSS (not stored locally) l2_proofs = [] for block in l2_blocks: l2_proofs.append({"dc_id": block.dc_id, "block_id": block.block_id, "proof": block.proof}) l3_block = l3_block_model.L3BlockModel( dc_id=keys.get_public_id(), current_ddss=party.get_address_ddss(ADDRESS), # Get DDSS from party, cached hourly block_id=str(block_id), timestamp=str(math.floor(time.time())), prev_proof=prev_proof, scheme=PROOF_SCHEME, l1_dc_id=l1_headers["dc_id"], l1_block_id=l1_headers["block_id"], l1_proof=l1_headers["proof"], l2_proofs=l2_proofs, ddss=str(ddss), l2_count=str(valid_block_count), regions=regions, clouds=clouds, ) sign_block(l3_block) return l3_block
def make_l3_block(): return l3_block_model.L3BlockModel( dc_id="an id", block_id="8474745", timestamp="129874", prev_proof="the previous block proof", l1_dc_id="l1 dc id", l1_block_id="l1 block id", l1_proof="l1 block proof", ddss="23452", l2_count="4", regions=["us-west-2"], clouds=["aws", "azure"], )
def create_l3_block(): return l3_block_model.L3BlockModel( dc_id="dc_id", block_id="123", timestamp="12345", prev_proof="prev_proof", scheme="trust", proof="proof", l1_dc_id="l1_dc_id", l1_block_id="l1_block_id", l1_proof="l1_proof", ddss="123", l2_count="3", regions=["region"], clouds=["cloud"], )
def test_setting_validations(self): l3block = l3_block_model.L3BlockModel(l1_block_id="l1_block_id", l1_dc_id="l1_dc_id") self.assertEqual(l3block.get_associated_l1_block_id(), {"l1_block_id"}) self.assertEqual(l3block.get_associated_l1_dcid(), "l1_dc_id")