Skip to content

Commit

Permalink
fix: tests (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
izyak authored Jan 3, 2024
1 parent 354914e commit af511b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import score.Context;
import score.DictDB;
import score.annotation.External;
import score.annotation.Optional;

import java.math.BigInteger;
import java.util.Arrays;
Expand All @@ -39,14 +40,17 @@ public class TendermintLightClient extends Tendermint implements ILightClient {
public static final BranchDB<String, DictDB<BigInteger, BigInteger>> processedHeights = Context.newBranchDB(
PROCESSED_HEIGHTS, BigInteger.class);

public TendermintLightClient(Address ibcHandler) {
public TendermintLightClient(Address ibcHandler, @Optional boolean update) {
this.ibcHandler = ibcHandler;
String neutronClient = "07-tendermint-2";
ClientState cs = ClientState.decode(getClientState(neutronClient));
Duration tp = cs.getTrustingPeriod();
tp.setSeconds(tp.getSeconds().multiply(BigInteger.TWO));
cs.setTrustingPeriod(tp);
clientStates.set(neutronClient, cs.encode());

if (update) {
String neutronClient = "07-tendermint-2";
ClientState cs = ClientState.decode(getClientState(neutronClient));
Duration tp = cs.getTrustingPeriod();
tp.setSeconds(tp.getSeconds().multiply(BigInteger.TWO));
cs.setTrustingPeriod(tp);
clientStates.set(neutronClient, cs.encode());
}
}

private void onlyHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void setup() throws Exception {
contextMock.when(() -> Context.getBlockTimestamp())
.thenReturn(System.currentTimeMillis() * 1000 + (sm.getBlock().getHeight() * 2_000_000));

client = sm.deploy(owner, TendermintLightClient.class, ibcHandler.getAddress());
client = sm.deploy(owner, TendermintLightClient.class, ibcHandler.getAddress(), false);

clientSpy = (TendermintLightClient) spy(client.getInstance());
client.setInstance(clientSpy);
Expand Down

0 comments on commit af511b1

Please sign in to comment.