diff --git a/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java b/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java index 95c010f09..2cb4ebd2d 100644 --- a/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java +++ b/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java @@ -354,7 +354,10 @@ public void faucetRequest(Context ctx) { from=TransactionPrepareResponse.class, type = "application/json", exampleObjects = { - @OpenApiExampleProperty(name = "value", value = "6") + @OpenApiExampleProperty(name = "sequence", value = "14"), + @OpenApiExampleProperty(name = "address", value = "12"), + @OpenApiExampleProperty(name = "source", value = "(* 2 3)"), + @OpenApiExampleProperty(name = "hash", value = "d00c0e81031103110232012a") } )}), @OpenApiResponse(status = "503", @@ -442,7 +445,7 @@ public void runTransact(Context ctx) { // Get ED25519 seed ABlob seed = Blobs.parse(req.get("seed")); if (!(seed instanceof ABlob)) - throw new BadRequestResponse("Ed25519 seed required for transact (e.g. as hex string)"); + throw new BadRequestResponse("Valid Ed25519 seed required for transact (hex string)"); if (seed.count() != AKeyPair.SEED_LENGTH) throw new BadRequestResponse("Seed must be 32 bytes"); diff --git a/convex-restapi/src/test/java/convex/restapi/RemoteClientTest.java b/convex-restapi/src/test/java/convex/restapi/RemoteClientTest.java index 77c9a6aea..b9d7e548c 100644 --- a/convex-restapi/src/test/java/convex/restapi/RemoteClientTest.java +++ b/convex-restapi/src/test/java/convex/restapi/RemoteClientTest.java @@ -13,7 +13,9 @@ import org.junit.jupiter.api.Test; import convex.core.crypto.AKeyPair; +import convex.core.data.AccountKey; import convex.core.data.Address; +import convex.core.init.Init; import convex.core.lang.Symbols; import convex.java.Convex; import convex.java.JSON; @@ -25,6 +27,8 @@ public class RemoteClientTest { static RESTServer server; static int port; static String host; + static AKeyPair skp; + static Address genesis=Init.GENESIS_ADDRESS; @BeforeAll public static void init() { @@ -33,6 +37,7 @@ public static void init() { rs.start(0); port=rs.getPort(); server=rs; + skp=s.getKeyPair(); host="http://localhost:"+port; } @@ -73,7 +78,7 @@ public void testFaucet() { } @Test - public void testQuery() { + public void testAccount() { Convex c=Convex.connect(host); AKeyPair kp=AKeyPair.generate(); Address addr=c.createAccount(kp); @@ -90,6 +95,19 @@ public void testQuery() { assertEquals(JSON.toString(kp.getAccountKey()),res.get("value")); } + @Test + public void testAccountGenesisInfo() { + Convex c=Convex.connect(host); + Address addr=genesis; + c.setAddress(addr); + + // Test values for basic new account + Map res=c.queryAccount(); + assertEquals(addr.longValue(),res.get("address")); + assertTrue(res.get("balance") instanceof Long); + assertEquals(skp.getAccountKey(),AccountKey.parse(res.get("key"))); + } + @Test public void testQueryAccount() { Convex c=Convex.connect(host); @@ -111,6 +129,20 @@ public void testQueryAccount() { assertNull(res); } + @Test + public void testTransactGenesis() { + Convex c=Convex.connect(host); + AKeyPair kp=skp; + Address addr=genesis; + c.setKeyPair(kp); + c.setAddress(addr); + + Map rm=c.transact("(+ 1 2)"); + // System.out.println(JSON.toPrettyString(rm)); + assertEquals(3L,rm.get("value")); + } + + @Test public void testTransactNoFunds() { Convex c=Convex.connect(host);