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

state_context.go fix for smartcontgract/storatec #116

Merged
merged 3 commits into from
Apr 3, 2021
Merged

Conversation

andriykutsevol
Copy link
Contributor

This fixes an incompatibility between the GetKey functions in the file:
https://github.com/0chain/0chain/blob/master/code/go/0chain.net/smartcontract/storagesc/models.go

and the IsHash function:

func IsHash(str string) bool {

IsHash wants HASH_LENGTH = 32
But GetKey functions add an arbitrary number of bytes to the HASH_LENGTH.

func (sn *StorageAllocation) GetKey(globalKey string) datastore.Key {
	return datastore.Key(globalKey + sn.ID)
}

Regression tests were made:
create allocation
upload file to allocation.
./zbox listallocations


key_hash := encryption.Hash(key)

if !encryption.IsHash(key_hash) {
Copy link
Contributor

@Sriep Sriep Mar 22, 2021

Choose a reason for hiding this comment

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

Can this test ever fail? You have just created key_hash to be a hash so isn't it always a hash? Same for insert and delete.

@Sriep Sriep self-requested a review March 23, 2021 09:37
@Sriep Sriep merged commit ee5704d into master Apr 3, 2021
@platsko platsko deleted the AndriyK_storagec branch May 9, 2021 14:46
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.

None yet

2 participants