Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/issues/216' into issues/216
Browse files Browse the repository at this point in the history
  • Loading branch information
meywood committed Sep 25, 2023
2 parents 4eb2b30 + d8d648a commit 74119e6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void transferToTheReceiverAccountTheTransferAmountOfAndThePaymentAmountOf
doDeploy(contextMap.get(StepConstants.SENDER_KEY_SK), contextMap.get(StepConstants.RECEIVER_KEY));
}

@And("the transfer approvals signer contains the {string} algo")
@And("the returned block header proposer contains the {string} algo")
public void theReturnedBlockHeaderProposerContainsTheAlgo(String algo) {
logger.info("the returned block header proposer contains the {} algo", algo);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.casper.sdk.e2e.steps;

import com.casper.sdk.e2e.utils.AssetUtils;
import com.casper.sdk.e2e.utils.CasperClientProvider;
import com.casper.sdk.e2e.utils.ContextMap;
import com.casper.sdk.model.clvalue.AbstractCLValue;
Expand All @@ -22,6 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.URL;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -48,7 +50,8 @@ public void thatTheJSONDeployIsLoaded(final String jsonFilename) throws IOExcept

logger.info("Given that the {} JSON deploy is loaded", jsonFilename);

final InputStream jsonIn = Objects.requireNonNull(getClass().getResource("/json/" + jsonFilename)).openStream();
final URL jsonUrl = AssetUtils.getStandardTestResourceURL("/json/" + jsonFilename);
final InputStream jsonIn = Objects.requireNonNull(jsonUrl.openStream());
assertThat(jsonIn, is(notNullValue()));

final Deploy transfer = new ObjectMapper().readValue(jsonIn, Deploy.class);
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/com/casper/sdk/e2e/steps/WasmStepDefinitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,17 @@ public class WasmStepDefinitions {
public void thatASmartContractIsInTheFolder(String wasmFileName, String contractsFolder) throws IOException {
logger.info("Give that a smart contract {string} is in the {string} folder");

final String wasmPath = "/" + contractsFolder + "/" + wasmFileName;
contextMap.put(StepConstants.WASM_PATH, wasmPath);
final URL resource = getClass().getResource(wasmPath);
//noinspection DataFlowIssue
assertThat(resource.openStream(), is(notNullValue()));
final URL wasmUrl = AssetUtils.getStandardTestResourceURL("/" + contractsFolder + "/" + wasmFileName);
contextMap.put(StepConstants.WASM_PATH, wasmUrl);
assertThat(wasmUrl.openStream(), is(notNullValue()));
}

@When("the wasm is loaded as from the file system")
public void whenTheWasmIsLoadedAsFromTheFileSystem() throws IOException, ValueSerializationException, NoSuchTypeException, GeneralSecurityException {
logger.info("Then when the wasm is loaded as from the file system");

final URL resource = getClass().getResource(contextMap.get(StepConstants.WASM_PATH));
final URL resource = contextMap.get(StepConstants.WASM_PATH);

//noinspection DataFlowIssue
final byte[] bytes = IOUtils.readBytesFromStream(resource.openStream());
assertThat(bytes.length, is(189336));

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/casper/sdk/e2e/utils/AssetUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.casper.sdk.e2e.utils;

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

/**
Expand All @@ -19,4 +22,10 @@ public static URL getFaucetAsset(final int networkId, final String keyFilename)
String path = String.format("/net-%d/faucet/%s", networkId, keyFilename);
return Objects.requireNonNull(AssetUtils.class.getResource(path), "missing resource " + path);
}

public static URL getStandardTestResourceURL(String jsonFilename) throws MalformedURLException {
final Path currentRelativePath = Paths.get("");
final String jsonPath = "file://" + currentRelativePath.toAbsolutePath() + "/sdk-std-test-resources" + jsonFilename;
return new URL(jsonPath);
}
}

0 comments on commit 74119e6

Please sign in to comment.