Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/db/src/network/network-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { networkCreateSchema } from './network-create-schema.ts'

export async function networkCreate(db: Database, input: NetworkCreateInput): Promise<string> {
const now = new Date()
// TODO: Add runtime check to ensure Network.type is valid
const parsedInput = networkCreateSchema.parse(input)

return db.transaction('rw', db.networks, async () => {
Expand Down
28 changes: 28 additions & 0 deletions packages/db/test/network-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,33 @@ describe('network-create', () => {
]]
`)
})

it('should throw an error with an invalid type', async () => {
// ARRANGE
expect.assertions(1)
const input = testNetworkCreateInput({
// @ts-expect-error we override the type
type: 'solana:custom',
})

// ACT & ASSERT
await expect(networkCreate(db, input)).rejects.toThrowErrorMatchingInlineSnapshot(`
[ZodError: [
{
"code": "invalid_value",
"values": [
"solana:devnet",
"solana:localnet",
"solana:mainnet",
"solana:testnet"
],
"path": [
"type"
],
"message": "Invalid option: expected one of \\"solana:devnet\\"|\\"solana:localnet\\"|\\"solana:mainnet\\"|\\"solana:testnet\\""
}
]]
`)
})
})
})
Loading