// Make sure the store function updates, and creates new only when not exceeding
// the limit defined by the application schema
Make sure the store function updates, and creates new only when not exceeding
the limit defined by the application schema
// Make sure the store function updates and creates new only when not exceeding // the limit defined by the application schema
func TestAlgorandMock_StoreGlobalSemantics(t *testing.T) {
	client := CreateAlgorandClientMock("", "")
	appId, err := client.CreateApplication(crypto.GenerateAccount(), "", "")
	assert.Nil(t, err)
	_, global := GenerateSchemasModel()
	kv := make([]models.TealKeyValue, global.NumByteSlice)
	for i, _ := range kv {
		kv[i].Key = strconv.Itoa(i)
		kv[i].Value.Bytes = "dummy"
	}
	err = client.StoreGlobals(crypto.Account{}, appId, kv)
	kv = make([]models.TealKeyValue, global.NumByteSlice)
	for i, _ := range kv {
		kv[i].Key = strconv.Itoa(i)
		kv[i].Value.Bytes = "dummy2"
	}
	err = client.StoreGlobals(crypto.Account{}, appId, kv)
	state, _ := client.GetApplicationByID(appId, context.Background())
	assert.Len(t, state.Params.GlobalState, int(global.NumByteSlice))
	for _, x := range state.Params.GlobalState {
		assertEqualBase64(t, x.Value.Bytes, "dummy2")
	}
	for i, _ := range kv {
		kv[i].Key = "new" + strconv.Itoa(i)
		kv[i].Value.Bytes = "dummy"
	}
	err = client.StoreGlobals(crypto.Account{}, appId, kv)
	state, _ = client.GetApplicationByID(appId, context.Background())
	assert.Len(t, state.Params.GlobalState, int(global.NumByteSlice))
	for _, x := range state.Params.GlobalState {
		assertEqualBase64(t, x.Value.Bytes, "dummy2")
	}
}
func TestAlgorandMock_StoreGlobalSemantics ( t * testing . T ) { client := CreateAlgorandClientMock ( " " , " " ) appId , err := client . CreateApplication ( crypto . GenerateAccount ( ) , " " , " " ) assert . Nil ( t , err ) _ , global := GenerateSchemasModel ( ) kv := make ( [ ] models . TealKeyValue , global . NumByteSlice ) for i , _ := range kv { kv [ i ] . Key = strconv . Itoa ( i ) kv [ i ] . Value . Bytes = " " } err = client . StoreGlobals ( crypto . Account { } , appId , kv ) kv = make ( [ ] models . TealKeyValue , global . NumByteSlice ) for i , _ := range kv { kv [ i ] . Key = strconv . Itoa ( i ) kv [ i ] . Value . Bytes = " " } err = client . StoreGlobals ( crypto . Account { } , appId , kv ) state , _ := client . GetApplicationByID ( appId , context . Background ( ) ) assert . Len ( t , state . Params . GlobalState , int ( global . NumByteSlice ) ) for _ , x := range state . Params . GlobalState { assertEqualBase64 ( t , x . Value . Bytes , " " ) } for i , _ := range kv { kv [ i ] . Key = " " + strconv . Itoa ( i ) kv [ i ] . Value . Bytes = " " } err = client . StoreGlobals ( crypto . Account { } , appId , kv ) state , _ = client . GetApplicationByID ( appId , context . Background ( ) ) assert . Len ( t , state . Params . GlobalState , int ( global . NumByteSlice ) ) for _ , x := range state . Params . GlobalState { assertEqualBase64 ( t , x . Value . Bytes , " " ) } }
Make sure the store function updates, and creates new only when not exceeding
the limit defined by the application schema
Make sure the store function updates and creates new only when not exceeding the limit defined by the application schema
// Schema model defines application storage size // We store MAX number the buffer can handle // New values, same keys // New keys, old values // Values and keys should NOT change, because buffer is already maxed out