You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In effort of making unit tests for a token and NFT registry I have accidently come across a minor bug in the testing functions from std. When trying to set the realm using std.TestSetRealm function to the realm that is being tested, the realm returned from calling std.PrevRealm() contains only the address and not the path. The print of that realm looks like this:
Exactly the same thing gets printed when there is no std.TestSetRealm at all. Is this expected behavior?
Other potential problems
TestSetOrigPkgAddr Has No Effect on PrevRealm
While trying to set the PrevRealm() I tried using the std.TestSetOrigPkgAddr. I got the similar result, as if nothing was set (see code and print output below). Is this supposed to happen since to my understanding TestSetOrigPkgAddr should set the entry realm?
Since all my tests are using the same std.TestSetRealm(std.NewCodeRealm("gno.land/r/matijamarjanovic/home")) I have tried making a separate function called setupTests() which would contain the two test set functions (no need for both this was an effort to make it work) but this has had the same result as the previous 2 points - PrevRealm() returning a Realm structure with path == "". Like the function was not even called in the tests.
To conclude, the only way I could set the tests to work is if I gave TestSetRealm an address argument of a realm that is not one being currently tested. Please correct me if I'm wrong and this is expected behavior.
The text was updated successfully, but these errors were encountered:
SetRealm sets the value of CurrentRealm, not PrevRealm. This is useful because it is the value of PrevRealm for any other realm that is called afterwards. does that answer your question?
SetRealm sets the value of CurrentRealm, not PrevRealm. This is useful because it is the value of PrevRealm for any other realm that is called afterwards. does that answer your question?
Well, yes, but I guess what I was trying to say is - without using TestSetRealm you can't access PrevRealm()'s package path
PrevRealm() Returns Empty Path After TestSetRealm
In effort of making unit tests for a token and NFT registry I have accidently come across a minor bug in the testing functions from std. When trying to set the realm using std.TestSetRealm function to the realm that is being tested, the realm returned from calling std.PrevRealm() contains only the address and not the path. The print of that realm looks like this:
code:
print output:
(struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm)
Exactly the same thing gets printed when there is no std.TestSetRealm at all. Is this expected behavior?
Other potential problems
TestSetOrigPkgAddr Has No Effect on PrevRealm
While trying to set the PrevRealm() I tried using the std.TestSetOrigPkgAddr. I got the similar result, as if nothing was set (see code and print output below). Is this supposed to happen since to my understanding TestSetOrigPkgAddr should set the entry realm?
code:
print output:
(struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm)
TestSetRealm in Setup Function Not Persisting
Since all my tests are using the same
std.TestSetRealm(std.NewCodeRealm("gno.land/r/matijamarjanovic/home"))
I have tried making a separate function called setupTests() which would contain the two test set functions (no need for both this was an effort to make it work) but this has had the same result as the previous 2 points - PrevRealm() returning a Realm structure with path == "". Like the function was not even called in the tests.To conclude, the only way I could set the tests to work is if I gave TestSetRealm an address argument of a realm that is not one being currently tested. Please correct me if I'm wrong and this is expected behavior.
The text was updated successfully, but these errors were encountered: