Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(internal): fake vstorage advance blockHeight #10933

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

mhofman
Copy link
Member

@mhofman mhofman commented Feb 4, 2025

refs: #10890
refs: #10931

Description

Add a driver to update the block height in fake vstorage cells.

Add test of sequence: false based deletion.

Security Considerations

None

Scaling Considerations

None

Documentation Considerations

Internal test hooks

Testing Considerations

Updated unit tests of fake storage

Upgrade Considerations

None

@mhofman mhofman added the automerge:squash Automatically squash merge label Feb 4, 2025
@mhofman mhofman requested review from dckc and gibson042 February 4, 2025 02:04
@mhofman mhofman requested a review from a team as a code owner February 4, 2025 02:04
Copy link

cloudflare-workers-and-pages bot commented Feb 4, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 68416ba
Status: ✅  Deploy successful!
Preview URL: https://30ee7db8.agoric-sdk.pages.dev
Branch Preview URL: https://mhofman-fake-vstorage-blocks.agoric-sdk.pages.dev

View logs

blockHeight: '0',
values: oldVal != null ? [oldVal] : [],
blockHeight: String(currentBlockHeight),
values: !streamCell && oldVal != null ? [oldVal] : [],
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion for clarifying the StreamCell reset behavior:

        case 'append': {
          trace('toStorage append', message);
          /** @type {StorageEntry[]} */
          const newEntries = message.args;
          for (const [key, value] of newEntries) {
            value != null || Fail`attempt to append with no value`;

            let oldVal = data.get(key);
            let streamCell;
            if (oldVal != null) {
              try {
                streamCell = JSON.parse(oldVal);
                assert(isStreamCell(streamCell));
              } catch (_err) {
                streamCell = undefined;
              }
              // StreamCells reset at block boundaries.
              if (streamCell?.blockHeight !== currentBlockHeight) {
                streamCell = undefined;
                oldVal = undefined;
              }
            }

            if (streamCell === undefined) {
              streamCell = {
                blockHeight: String(currentBlockHeight),
                values: oldVal != null ? [oldVal] : [],
              };
            }

            streamCell.values.push(value);
            data.set(key, JSON.stringify(streamCell));
          }
          break;
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry this was set on auto merge. I did consider something along those lines. I agree it does read better

@mergify mergify bot merged commit 5fa1324 into master Feb 4, 2025
87 of 92 checks passed
@mergify mergify bot deleted the mhofman/fake-vstorage-blocks branch February 4, 2025 02:49
mergify bot added a commit that referenced this pull request Feb 7, 2025
refs: #10933

## Description
Forgot some test updates in the previous PR
Also it was on automerge so I couldn't include @gibson042 's [review suggestion](#10933 (comment)) 

### Security Considerations
None

### Scaling Considerations
None

### Documentation Considerations
Internal test hooks

### Testing Considerations
Updated unit tests of fake storage

### Upgrade Considerations
None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants