Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make ToAddress in routeAction nullable #427

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,29 @@ void tokenFallback_swapStable() throws Exception {
}
}

@Test
void tokenFallback_swapToICX() throws Exception {
// Arrange
BigInteger USDToSwap = BigInteger.TEN.multiply(ICX);
BigInteger sICXResult = BigInteger.valueOf(100).multiply(ICX);
BigInteger ICXResult = BigInteger.valueOf(110).multiply(ICX);
List<RouteAction> actions = new ArrayList<>(2);
actions.add(new RouteAction(SWAP, balanced.sicx.getAddress()));
actions.add(new RouteAction(SWAP, null));
when(balanced.sicx.mock.balanceOf(routerScore.getAddress())).thenReturn(sICXResult);
routerScore.getAccount().addBalance("ICX", ICXResult);

Account newReceiver = sm.createAccount();
byte[] data = new RouteData("_swap", newReceiver.getAddress().toString(), BigInteger.ZERO, actions).toBytes();

// Act
routerScore.invoke(balanced.baln.account, "tokenFallback", owner.getAddress(), USDToSwap,
data);

// Assert
assertEquals(ICXResult, newReceiver.getBalance());
}

@Test
void tokenFallback_swapStableWithoutOptField_AndMixedSwapTypes() throws Exception {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
RouteAction obj = new RouteAction();
reader.beginList();
obj.action = reader.readInt();
obj.toAddress = reader.readAddress();
obj.toAddress = reader.readNullable(Address.class);

Check warning on line 28 in score-lib/src/main/java/network/balanced/score/lib/structs/RouteAction.java

View check run for this annotation

Codecov / codecov/patch

score-lib/src/main/java/network/balanced/score/lib/structs/RouteAction.java#L28

Added line #L28 was not covered by tests
reader.end();
return obj;
}

public void writeObject(ObjectWriter writer) {
writer.beginList(2);
writer.write(this.action);
writer.write(this.toAddress);
writer.writeNullable(this.toAddress);

Check warning on line 36 in score-lib/src/main/java/network/balanced/score/lib/structs/RouteAction.java

View check run for this annotation

Codecov / codecov/patch

score-lib/src/main/java/network/balanced/score/lib/structs/RouteAction.java#L36

Added line #L36 was not covered by tests
writer.end();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Versions {
public final static String DEX = "v1.1.1";
public final static String GOVERNANCE = "v1.0.2";
public final static String REBALANCING = "v1.0.0";
public final static String ROUTER = "v1.1.3";
public final static String ROUTER = "v1.1.4";
public final static String STAKEDLP = "v1.0.1";
public final static String BOOSTED_BALN = "v1.1.0";
public final static String BRIBING = "v1.0.1";
Expand All @@ -45,7 +45,7 @@ public class Versions {
public final static String SAVINGS = "v1.0.0";
public final static String TRICKLER = "v1.0.0";

public final static String SPOKE_ASSET_MANAGER = "v1.0.0";
public final static String SPOKE_ASSET_MANAGER = "v1.0.1";
public final static String SPOKE_XCALL_MANAGER = "v1.0.0";
public final static String SPOKE_BNUSD = "v1.0.0";
}
Loading