Skip to content

[Neo MemStore] fix memstore commit bug#3288

Merged
shargon merged 2 commits intoneo-project:masterfrom
Jim8y:memstore-cache
Jun 3, 2024
Merged

[Neo MemStore] fix memstore commit bug#3288
shargon merged 2 commits intoneo-project:masterfrom
Jim8y:memstore-cache

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jun 1, 2024

Description

This pr fixes the issue that when the neosystem is initialized with memstore, then called with neoSystem.StoreView;, then the commit operation will fail as the snapshot is null (snapshot = store as ISnapshot; gets null as memorystore is IStore only).

exception:

Test method Neo.UnitTests.Persistence.UT_MemoryStore.NeoSystemTest threw exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
    at Neo.Persistence.SnapshotCache.Commit() in /Users/jinghuiliao/git/neo/src/Neo/Persistence/SnapshotCache.cs:line 51
   at Neo.UnitTests.Persistence.UT_MemoryStore.NeoSystemTest() in /Users/jinghuiliao/git/neo/tests/Neo.UnitTests/Persistence/UT_MemoryStore.cs:line 67
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Fixes # (issue)

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • NeoSystemStoreViewTest

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Jim8y Jim8y requested a review from a team June 1, 2024 15:44
@Jim8y Jim8y changed the title [Neo MemStore] fix memstore commit issue [Neo MemStore] fix memstore commit bug Jun 1, 2024
@Jim8y Jim8y added the Bug Used to tag confirmed bugs label Jun 1, 2024
@Jim8y Jim8y requested a review from a team June 2, 2024 00:24
@shargon shargon merged commit fd1edf0 into neo-project:master Jun 3, 2024
@Jim8y Jim8y deleted the memstore-cache branch June 3, 2024 08:11
}

[TestMethod]
public void NeoSystemStoreViewTest()
Copy link
Member

Choose a reason for hiding this comment

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

Good test

@Jim8y Jim8y mentioned this pull request Jun 15, 2024
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Used to tag confirmed bugs Waiting for Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants