Add funded cellular mutation proposal
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (checks) (push) Failing after 43s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 53s
Foundation / checks (client) (push) Canceled after 2m59s
Foundation / checks (network) (push) Canceled after 2m19s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (checks) (push) Failing after 43s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 53s
Foundation / checks (client) (push) Canceled after 2m59s
Foundation / checks (network) (push) Canceled after 2m19s
This commit is contained in:
@@ -352,6 +352,54 @@ void successors_keep_their_parents_schema() {
|
||||
}
|
||||
}
|
||||
|
||||
void mutation_funding_is_exact_and_atomic() {
|
||||
const auto parent = build(draft());
|
||||
const auto context_value = context(33, 8);
|
||||
const auto offered = mutation_candidates(parent, context_value);
|
||||
CHECK(offered);
|
||||
constexpr Inventory reserve = pooled(1'000'000'000);
|
||||
for (const auto& candidate : offered->candidates) {
|
||||
const auto transition =
|
||||
fund_mutation(parent, context_value, *offered, candidate.operator_id, 99, 42, reserve);
|
||||
CHECK(transition);
|
||||
const auto before =
|
||||
metabolic_budget(parent, context_value.growth, context_value.environment);
|
||||
CHECK(before);
|
||||
for (std::size_t channel = 0; channel < reserve.matter.size(); ++channel) {
|
||||
CHECK(before->body.matter[channel].value + reserve.matter[channel].value ==
|
||||
transition->body.matter[channel].value +
|
||||
transition->reserve.matter[channel].value);
|
||||
}
|
||||
CHECK(reserve.energy.value - transition->reserve.energy.value ==
|
||||
transition->intake.energy.value);
|
||||
CHECK(transition->successor.parents().size() == 1 &&
|
||||
transition->successor.parents().front() == parent.id());
|
||||
}
|
||||
|
||||
// Acquiring a larger target-size capability needs construction matter and
|
||||
// energy. Empty reserves refuse the proposal and leave the caller's balance
|
||||
// unchanged.
|
||||
bool checked_unfunded = false;
|
||||
for (std::uint64_t seed = 1; seed <= 200 && !checked_unfunded; ++seed) {
|
||||
const auto offer = mutation_candidates(parent, context(seed, 8));
|
||||
CHECK(offer);
|
||||
for (const auto& candidate : offer->candidates) {
|
||||
if (candidate.target != Capability::target_size ||
|
||||
candidate.effect != MutationEffect::adjust_up) {
|
||||
continue;
|
||||
}
|
||||
constexpr Inventory empty{};
|
||||
const auto result = fund_mutation(parent, context(seed, 8), *offer,
|
||||
candidate.operator_id, 99, 42, empty);
|
||||
CHECK(!result && result.error() == MutationError::insufficient_funding);
|
||||
CHECK(empty == Inventory{});
|
||||
checked_unfunded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK(checked_unfunded);
|
||||
}
|
||||
|
||||
int main() try {
|
||||
the_same_context_always_offers_the_same_candidates();
|
||||
offers_are_canonical_and_unranked();
|
||||
@@ -363,6 +411,7 @@ int main() try {
|
||||
invalid_contexts_are_refused();
|
||||
every_eligible_operator_is_offered_and_none_is_favoured();
|
||||
successors_keep_their_parents_schema();
|
||||
mutation_funding_is_exact_and_atomic();
|
||||
std::cout << "PASS mutation catalog, uniform seeded offers and guarded selection\n";
|
||||
return 0;
|
||||
} catch (...) {
|
||||
|
||||
Reference in New Issue
Block a user