-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to allow setting per-backend configuration (#336)
- Loading branch information
Showing
10 changed files
with
295 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AptosConfig, LedgerInfo, getAptosFullNode } from "../../../src"; | ||
|
||
const aptosConfig = new AptosConfig({ | ||
clientConfig: { | ||
HEADERS: { clientConfig: "clientConfig-header" }, | ||
API_KEY: "api-key", | ||
}, | ||
fullnodeConfig: { HEADERS: { fullnodeHeader: "fullnode-header" } }, | ||
indexerConfig: { HEADERS: { indexerHeader: "indexer-header" } }, | ||
faucetConfig: { HEADERS: { faucetHeader: "faucet-header" }, AUTH_TOKEN: "auth-token" }, | ||
}); | ||
|
||
// All tests are expected to catch becuase server call will fail | ||
// due to a fake API_KEY. But that is ok because we just want | ||
// to test the config we set | ||
describe("get request", () => { | ||
describe("fullnode", () => { | ||
test("it sets correct headers on get request", async () => { | ||
try { | ||
await getAptosFullNode<{}, LedgerInfo>({ | ||
aptosConfig, | ||
originMethod: "testGetFullnodeQuery", | ||
path: "", | ||
}); | ||
} catch (e: any) { | ||
expect(e.request.overrides.API_KEY).toEqual("api-key"); | ||
expect(e.request.overrides.HEADERS).toHaveProperty("clientConfig"); | ||
expect(e.request.overrides.HEADERS.clientConfig).toEqual("clientConfig-header"); | ||
expect(e.request.overrides.HEADERS).toHaveProperty("fullnodeHeader"); | ||
expect(e.request.overrides.HEADERS.fullnodeHeader).toEqual("fullnode-header"); | ||
// Properties should not be included | ||
expect(e.request.overrides.HEADERS).not.toHaveProperty("faucetConfig"); | ||
expect(e.request.overrides.HEADERS).not.toHaveProperty("AUTH_TOKEN"); | ||
expect(e.request.overrides.HEADERS).not.toHaveProperty("indexerHeader"); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.