import blockchain.*; import utils.config.ServerEnvironment; import java.nio.file.*; import java.util.HexFormat; import java.util.List; public class ServerEnvironmentCheck { public static void main(String[] args) throws Exception { boolean test = Boolean.parseBoolean(args[0]); if (ServerEnvironment.TEST_MODE != test || !ServerEnvironment.ARWEAVE_APP_TAG.equals(test ? "test5570" : "SHiNE") || !ServerEnvironment.SOLANA_CLUSTER.equals(test ? "devnet" : "mainnet-beta")) throw new AssertionError("wrong environment"); for (String x : new String[]{null,"true","False","invalid",""}) if (!ServerEnvironment.isTestMode(x)) throw new AssertionError("unsafe default"); if (ServerEnvironment.isTestMode("false")) throw new AssertionError("explicit production ignored"); var row = Files.readAllLines(Path.of(args[1])).get(1).split("\t"); var item = new Ans104DataItem(HexFormat.of().parseHex(row[6])); try { CoreContentTransport.requireApp(item); if (!test) throw new AssertionError("test CORE accepted in production"); } catch (CoreContentTransport.WrongAppNamespace e) { if (test) throw e; } System.out.println("PASS environment=" + ServerEnvironment.ARWEAVE_APP_TAG + ", cluster=" + ServerEnvironment.SOLANA_CLUSTER); } }