use of org.batfish.z3.expr.StateExpr in project batfish by batfish.
the class ReachabilityProgramOptimizerTest method freshQueryStateExpr.
private StateExpr freshQueryStateExpr() {
StateExpr stateExpr = freshStateExpr();
_queries.add(new QueryStatement(stateExpr));
return stateExpr;
}
use of org.batfish.z3.expr.StateExpr in project batfish by batfish.
the class RelationCollectorTest method testTestStateExpr.
@Test
public void testTestStateExpr() {
StateExpr b1 = newStateExpr();
StateExpr b2 = newStateExpr();
assertThat(b1, Matchers.not(equalTo(b2)));
}
use of org.batfish.z3.expr.StateExpr in project batfish by batfish.
the class RelationCollectorTest method testVisitTransformationRuleStatement.
/**
* Test that collectRelations traverses the child of a TransformationRuleStatement.
*/
@Test
public void testVisitTransformationRuleStatement() {
StateExpr b1 = newStateExpr();
StateExpr b2 = newStateExpr();
StateExpr t1 = newStateExpr();
TransformationRuleStatement expr1 = new TransformationRuleStatement(t1);
Set<String> expectedRelations1 = ImmutableSet.of(getNodName(_input, t1));
TransformationRuleStatement expr2 = new TransformationRuleStatement(TrueExpr.INSTANCE, ImmutableSet.of(b1), ImmutableSet.of(b2), t1);
Set<String> expectedRelations2 = ImmutableSet.of(getNodName(_input, b1), getNodName(_input, b2), getNodName(_input, t1));
assertThat(collectRelations(_input, expr1), equalTo(expectedRelations1));
assertThat(collectRelations(_input, expr2), equalTo(expectedRelations2));
}
use of org.batfish.z3.expr.StateExpr in project batfish by batfish.
the class DefaultTransitionGenerator method visitPreOutEdgePostNat_generateNoMatchSourceNatRules.
private void visitPreOutEdgePostNat_generateNoMatchSourceNatRules(String node1, String iface1, String node2, String iface2) {
List<Entry<AclPermit, BooleanExpr>> sourceNats = _input.getSourceNats().getOrDefault(node1, ImmutableMap.of()).getOrDefault(iface1, ImmutableList.of());
ImmutableSet.Builder<StateExpr> preStates = ImmutableSet.builder();
preStates.add(new PreOutEdge(node1, iface1, node2, iface2));
sourceNats.stream().map(Entry::getKey).map(aclPermit -> new AclDeny(aclPermit.getHostname(), aclPermit.getAcl())).forEach(preStates::add);
_rules.add(new TransformationRuleStatement(new EqExpr(new VarIntExpr(TransformationHeaderField.NEW_SRC_IP), new VarIntExpr(TransformationHeaderField.NEW_SRC_IP.getCurrent())), preStates.build(), ImmutableSet.of(), new PreOutEdgePostNat(node1, iface1, node2, iface2)));
}
use of org.batfish.z3.expr.StateExpr in project batfish by batfish.
the class ReachabilityProgramOptimizerTest method pruneIrrelevant.
/*
* No query statement, so everything is irrelevant
*/
@Test
public void pruneIrrelevant() {
StateExpr state1 = freshStateExpr();
addRuleFor(state1);
StateExpr state2 = freshStateExpr();
addRuleFor(state2, state1);
Set<RuleStatement> rules = optimize();
assertThat(rules, empty());
}
Aggregations