Skip to content

feat: [Issue-185] Token Provider Tests #365

Merged
jkbrooks merged 16 commits into
elizaOS:mainfrom
normand1:dn/token-provider-tests
Nov 20, 2024
Merged

feat: [Issue-185] Token Provider Tests #365
jkbrooks merged 16 commits into
elizaOS:mainfrom
normand1:dn/token-provider-tests

Conversation

@normand1
Copy link
Copy Markdown
Contributor

@normand1 normand1 commented Nov 16, 2024

Relates to:

#185

Risks

Low: Only modification to src code files was adding optional syntax an

Background

What does this PR do?

  • Removes jest in favor of vitest as discussed in this issue: Core Unit Tests #340
  • Fixes tests that were no longer running in packages/core/src/tests/token.test.ts

What kind of change is this?

Improvements - Tests

See Issue above

Documentation changes needed?

My changes do not require a change to the project documentation.

Testing

pnpm -w run test -- 'src/tests/token.test.ts'

Where should a reviewer start?

pnpm install
pnpm run build
pnpm -w run test -- 'src/tests/token.test.ts'

Detailed testing steps

@normand1 normand1 mentioned this pull request Nov 16, 2024
@normand1
Copy link
Copy Markdown
Contributor Author

@ponderingdemocritus This is based on your earlier instructions to include and use vitest:
#340 (comment)

@ponderingdemocritus ponderingdemocritus changed the title [Issue-185] Token Provider Tests feat: [Issue-185] Token Provider Tests Nov 17, 2024
Comment thread packages/adapter-sqlite/package.json Outdated
},
"exports": {
".": "./dist/index.js",
"./sqlite_vec": "./dist/sqlite_vec.js"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is needed - exported at index

Comment thread packages/plugin-solana/src/index.ts Outdated
import { Connection } from "@solana/web3.js";
import { PublicKey } from "@solana/web3.js";

export { TokenProvider, WalletProvider, Connection, PublicKey };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the solana exports and import where needed from the packages

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this was left over from another test I was working on, but ended up simplifying for this first PR

Copy link
Copy Markdown
Contributor

@ponderingdemocritus ponderingdemocritus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good start - see comments

@normand1
Copy link
Copy Markdown
Contributor Author

normand1 commented Nov 17, 2024

@ponderingdemocritus Thanks for the feedback! Just pushed an update based on comments

Comment thread packages/core/src/tests/token.test.ts Outdated
Comment on lines +16 to +20
"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh",
new WalletProvider(
new Connection("https://api.mainnet-beta.solana.com"),
new PublicKey("2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh")
)
Copy link
Copy Markdown
Contributor

@mcp97 mcp97 Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hard coding these can we move these into a constants file? Thank you!

Comment thread packages/core/src/tests/token.test.ts Outdated
Comment on lines +68 to +70
// Ensure the mock was called
expect(fetchSpy).toHaveBeenCalled();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this as the line below does the same check and there this is redundant

@@ -0,0 +1,6 @@
export interface User {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that this type hasn't already been declared and can't be reused. Could be mistaken but wanted to point it out thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is intended to generically represent the different User types used across packages in the agent runtime based on whether we're using sqlite, supabase or sqljs. I couldn't find an abstract type that currently exists for this, but I'd be happy to replace it here if there is one. If there isn't one then I agree this would be helpful to have a real type that does this instead of this one sitting in a test file :)

Comment on lines +56 to +62
user = {
id: zeroUuid,
email: "test@example.com",
} as User;
session = {
user: user,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: user can be inlined here

Comment on lines +123 to +129
user = {
id: zeroUuid,
email: "test@example.com",
} as User;
session = {
user: user,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

}

const runtime = new AgentRuntime({
serverUrl: "https://api.openai.com/v1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a const we can use here

import { describe, expect, it } from "vitest";

describe("Basic Test Suite", () => {
it("should run a basic test", () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

Copy link
Copy Markdown
Contributor

@mcp97 mcp97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good thanks for doing this - some code quality changes to make then can accept!

Copy link
Copy Markdown
Contributor

@mcp97 mcp97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. It's ready to go after addressing comments

@normand1
Copy link
Copy Markdown
Contributor Author

Thanks for working on this. It's ready to go after addressing comments

Awesome thank you for the review, taking a look at making those updates now

@mcp97
Copy link
Copy Markdown
Contributor

mcp97 commented Nov 19, 2024

Also, forgot to mention please address the merge conflicts thanks :)

@normand1
Copy link
Copy Markdown
Contributor Author

@monilpat I believe I've addressed all feedback, ready for someone to take another look, thanks!

@jkbrooks
Copy link
Copy Markdown
Contributor

FYI, we now have two conflicting files here

packages/core/src/tests/goals.test.ts
pnpm-lock.yaml

@monilpat @normand1 can we resolve before merge?

@normand1
Copy link
Copy Markdown
Contributor Author

@jkbrooks Resolved conflicts

@mcp97
Copy link
Copy Markdown
Contributor

mcp97 commented Nov 20, 2024

Cool with the resolved conflicts LGTM!

@jkbrooks jkbrooks merged commit bea5567 into elizaOS:main Nov 20, 2024
lalalune pushed a commit that referenced this pull request May 3, 2026
feat: [Issue-185] Token Provider Tests
FranceFlapjack pushed a commit to FranceFlapjack/eliza that referenced this pull request May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants