def test_ITE(self): cs = ConstraintSet() a = cs.new_bool() b = cs.new_bool() c = cs.new_bool() cs.add(b == True) cs.add(c == False) cs.add(a == Operators.ITE(b == c, b, c)) self.assertTrue(solver.check(cs)) self.assertEqual(solver.get_value(cs, a), False)
# Add a source and remove it market_oracle.addSource(m.make_symbolic_value()) market_oracle.removeSource(m.make_symbolic_value()) # Get size market_oracle.whitelistSize() if m.count_running_states() == 0: print("[+] WARNING expected at least one running_state! see %s" % m.workspace) for state in m.running_states: sym_tx = state.platform.human_transactions[tx_offset:] addSource_input = h.get_calldata_uint_arg(sym_tx[0].data, arg_ix=0, bits=160) removeSource_input = h.get_calldata_uint_arg(sym_tx[1].data, arg_ix=0, bits=160) whitelistSize = h.get_return_data(state.platform.human_transactions[-1]) # if we added the same source as we removed, whitelist size shall be 0 m.generate_testcase( state, 'The addSource and removeSource made whitelistSize be in an unexpected state', only_if=Operators.ITE( addSource_input == removeSource_input, whitelistSize != 0, # if sources addresses were same, the whitelist size shall not be 0 whitelistSize != 1 # if the addresses differs, the whitelist size shall be 1 ) ) h.finalize(m)